1

I need to perform SFTP automation (to get rid of the password prompt). How can I do this?

1

4 Answers 4

2

You need to set up a public/private key. How can I automate an SFTP transfer between two servers?

1

My suggestion is using SSH authorized_keys. You will need to create a key on the client side (using ssh-keygen) and then copy the public key to the target side.

client-machine% ssh-keygen -t rsa
client-machine% scp ~/.ssh/id_rsa.pub user@target-machine:~/.ssh/authorized_keys2

Note that if you want to access target-machine from two or more "clients", you can not copy the id_rsa.pub to authorized_keys2 directly. You will need to open authorized_keys2 and paste the id_rsa.pub from each client machine on it (or use the line below to append the content)

client-machine% cat ~/.ssh/id_rsa.pub | ssh user@target-machine \
                'cat >> .ssh/authorized_keys'

Now you can use ssh/scp without user/password information:

client-machine% ssh user@target-machine
client-machine% scp file user@target-machine:~/file
1

Take a look at the VisualCron automation suite. It has built in automation for SFTP and SSH as well as normal FTP. http://www.visualcron.com

0

If security is not a concern then the password can be in clear text in your script. E.g. on Microsoft Windows using pscp from the PuTTY package.

Example:

"d:\putty0.58\pscp"  -pw MyNotSoSecretPassWord  u:\outGoing\someFileToTransfer.7z  [email protected]:/srv/www/htdocs/1/MSQuantDynamics/someFileToTransfer.7z

Password: MyNotSoSecretPassWord. User name: kingOfTheHill. Host: www.pil.sdu.dk.

The sftp server in our case runs on a Linux based server.

You must log in to answer this question.