How to set up a ssh key login

From HostThyself

Jump to: navigation, search

ssh key can be used to login to remote server without using password. For added security, you can disable password login and use ssh key only.

On the local computer (your desktop or the server that you will ssh from). If you are on a windows computer, you need to get your program (eg. putty) to generate the keys.

Create/generate a key

 ssh-keygen -t rsa

For using in cron job or scripting, you may need a key without a passphrase so that the script will not be waiting for an input

ssh-keygen -t rsa -N 

copy the public key to the remote server (the server that you will ssh to).

scp .ssh/id_rsa.pub username@remote:~/.ssh/authorized_keys

If you have multiple keys from different servers/computers, append the public key to the end of the authorized_keys file

Try login to the remote server. If your key has a passphrase, you will be prompted for it. All goes well you will be login on the remote server.

Personal tools