Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

migrated from Jul 30 '09 at 19:51

This question came from our site for professional and enthusiast programmers.

What platform are you on? – Peter Mortensen Jul 30 '09 at 22:48

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

share|improve this answer

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/ 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 to authorized_keys2 directly. You will need to open authorized_keys2 and paste the from each client machine on it (or use the line below to append the content)

client-machine% cat ~/.ssh/ | 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
share|improve this answer

Take a look at the VisualCron automation suite. It has built in automation for SFTP and SSH as well as normal FTP.

share|improve this answer

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.


"d:\putty0.58\pscp"  -pw MyNotSoSecretPassWord  u:\outGoing\someFileToTransfer.7z

Password: MyNotSoSecretPassWord. User name: kingOfTheHill. Host:

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

share|improve this answer

You must log in to answer this question.