Automated file transfer with sftp
January 06, 2015 —
BarryK
I have a script that uploads files to a website, using sftp.
sftp asks for a password to login, and I have to manually type it in every time.
So, I looked into how to automate password entry. This is a neat solution, however it is considered to be the least secure method:
# echo -e '<commands>' | sshpass -p <password> sftp [-P <port>] <username>@<host>
<
An example:
# echo -e 'pwd\nquit' | sshpass -p mypasswd sftp -P 2222 mrperson@login.mywebsite.com
<
The default is port 22, which many hosts use, so most likely the -P option isn't required.
Home page for sshpass:
http://sourceforge.net/projects/sshpass/
Tags: linux