21 July 2011

SCP / SSH without password

To be able to log into a remote linux host without a password, you must generate a public / private key pair on the local host and copy the public key to the remote host. You would do this if you wanted to SCP some files via a script perhaps.

First, generate the key pair on the host that you are connecting from.

ssh-keygen -t dsa

Accept defaults.. can put passphrase if you wish for extra security.

Copy id_dsa.pub to the remote host somewhere. Then add it to the authorized_keys file under the home directory of the user that you are trying to log in as.

For instance if you are wanting to send a file to the remote server as user 'bob'...

copy the id_dsa.pub file to /tmp on the remote server
log in to the remote server as bob
cat /tmp/id_dsa.pub >> ~/.ssh/authorized_keys

Now you should be able to ssh or scp something to the remote host and not be prompted for a password.


No comments:

Post a Comment