Setup SFTP to use public-key authentication

user290 picture user290 · Feb 9, 2010 · Viewed 36.4k times · Source

How do you setup server to server SFTP to use public-key authentication instead of user account and password?

Answer

bhups picture bhups · Feb 9, 2010

In the client you need to generate its public key and add it to server's authorized key list.

The following are the commands you can use.

On client machine

ssh-keygen -t dsa -f id_dsa
mv id_dsa* ~/.ssh/
scp ~/.ssh/id_dsa.pub USER_NAME@SERVER:~/.ssh/HOST_NAME.key

On the server

cat ~/.ssh/HOST_NAME.key >> ~/.ssh/authorized_keys2