Wanna upload files to a linux box? Yeah – get a ssh trust established and sftp your files. Simple, huh..
Now – wanna sftp files to an external drive authenticated by a password? Can’t establish trust relationship. Easy – sftp, provide password, upload files, huh..
Cool – what if you wanna automate the process and avoid the password entry. Here you go. Use ssshpass. This allows you to store password in a file and use this file for authentication. Pretty useful for automating some stuff out there.. La La La La La
apt-get install sshpass
Using sshpass to upload files
sshpass -f ~/path_to_password/pass.txt sftp email@example.com:/pools/path/ << EOF put backup.tar EOF