sshpass, scp and feh. Sending files over ssh without prompting for a password

I got a Raspberry Pi as a webcam/timelapse setup. I thought it would be fun to also send it to my other Pi so it would show up on my desktop.

This how I did it.

First I needed to send the file from the PiCam to the PiDesktop and I use SSH and SCP. The thing is, with SCP you need to enter a password and because we run it in on a cronjob we have a problem.

This is how you can get arround that. Use SSHPASS.

First we need to install sshpass:

Then you can use it like this:

Yeah its not secure. Follow the links to read more about a better approach.

As it arrives on the PiDesktop, FEH will pick it up and sends it to a nice picture windows.

Sources:
https://www.tecmint.com/sshpass-non-interactive-ssh-login-shell-script-ssh-password/
https://linux.die.net/man/1/feh
https://www.linux.com/learn/cool-linux-command-line-image-management-hacks

This is a better way to connect with SCP and a password:
https://kb.iu.edu/d/aews and https://alvinalexander.com/linux-unix/how-use-scp-without-password-backups-copy

Centos fail2ban error

With the latest version of Fail2ban I got this error on some Centos servers that Fail2ban would not start anymore.

This is the quick fix:

Add to your jail.conf:

Found the above solution here: https://github.com/fail2ban/fail2ban/issues/44

 

 

how to fix a dead Li-ion samsung battery

More then a year a go I put away my old Samsung phone in its box.

Totally forgotten about it I had an idea to play with it again so I tried to start it up but nothing happend.  We just need to put it in the charger again right? After a few hours charging the phone was still playing dead. Nothing nada njet niks!

Searching on the many webpages about Li-ion batteries I came to the conclusion that the best thing to do is to buy a new battery. uh huh. Now that is not going to happen.

We know that you need a bit of current in the battery for some phones to enable their in build charging circuit. But how to get it charged without a fancy charger?

If you don’t mind to let a battery explode in your face then there is a little trick.
Needless to say that you might void your warranty and you might loose some limbs doing this.. We gonna jump start it! If it works for a car why not try that for a Li-ion battery…

If you want the science behind it, why this actually works, than please search and feel free to comment 😉

This is what I did:

Strip one side of the USB cable,and tape the right poles to the battery.

USB cabble to Samsung battery

As most of the time, red goes to the + and black to the –

I used some high temperature tape that u can use for soldering. But any good tape will do.

Plugin the USB cable and keep your fingers crossed now you still got them.

After 20 minutes I pulled the plug, got rid of the the tape and inserted the battery in the phone.

Now its charging, and the phone works!

Did I tell you that this isn’t the right way to do it?
I warned you about the fact that it could blow up in your face?
I mentioned that it might void your Samsung warranty?

Yes I did! Happy hacking!

Phone is charging again

Chatting with Max from Frozen Electronics and he came up with this tip:

“Max: You could destroy the battery, the chargers have a current-limiting PNP transistor in them!

Max: In the future, there’s a pretty simple constant current circuit you can build if you’ve got a P-channel MOSFET around somewhere. the chips are a dime a dozen on Newark/digikey (even ebay) and you can control the voltage and charge speed with potentiometers. almost like a universal li-po charger.

Max: Here’s the chip, the datasheet has the circuit in it, it’s really easy to use. there’s versions of the chip for all the common li-ion voltages (4.1, 4.2, 8.2, 8.4). It’s all based around a p-channel mosfet pass transistor. http://www.ti.com/product/bq2057

Thank’s max. Might try that one next time!

Fix mount issues Linux and Windows 8 NTFS

Windows 8 has a option that you can boot faster. It stores (hibernates) your system. Sometimes Linux can’t mount your local disks and it will give you this kinda error:

Unable to mount location

Error mounting /dev/sda2 at /media/pieter/DATA: Command-line `mount -t “ntfs” -o “uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177” “/dev/sda2” “/media/pieter/DATA”‘ exited with non-zero exit status 14: The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Failed to mount ‘/dev/sda2’: Operation not permitted
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the ‘ro’ mount option.

What worked for me was to disable the “fast start” option in windows 8.

1. Open Control Panel and choose Power Options.
2. Click on “Choose what the power buttons do”.
3. Click on “Change settings that are currently unavailable”.
4. Uncheck “Turn on fast startup (recommended)”.

If you want to try some more options this page might help you:

http://www.hecticgeek.com/2013/01/mount-windows-8-partition-ubuntu-hybrid-boot/

 

 

Fail2ban and wordpress

If you use fail2ban on your server and you are running WordPress you could use this plugin:

https://wordpress.org/plugins/wp-fail2ban/

“WP fail2ban logs all login attempts, whether successful or not, to syslog using LOG_AUTH.”

So now when kiddies try to “hack” your login page, Fail2Ban will kick in and do its job.

wordpress.conf:

WP fail2ban plugin: