For this to work the servers /etc/ssh/sshd_config must have
RSAAuthentication yes
PubkeyAuthentication yes
On the local client, in a terminal, as the user you normally use to ssh with (like your normal username)
This generates an RSA key for SSHv2 (v2 is the -t paramater)
This creates 2 files in your /home/username/.ssh/ folder
id_rsa, which is the private key
id_rsa.pub which is the public key
Now we have to get that public key file on to the server your are connecting to with ssh.
scp -P 22 /home/username/.ssh/id_rsa.pub serverusername@server.com:/home/serverusername/.ssh/
Notes, if we always login as say user1 on the server (like ssh user1@server.com) then we want that public key authorized_keys2 file \
to be in the /home/user1/.ssh folder, not the root/.ssh folder.
OK, now on the server side (login to the ssh server)
If the authorized_keys2 file does not exist the first time, make sure you set correct permissions on it after it's created
touch authorized_keys2
chmod 600 authorized_keys2
Now we copy the contents of that \
keyfile into the authorized_keys2 file. NOTE that multiple clients can connect to this server without using a password. \
So that authorized_keys2 file will have 1 line for each client that can connect. So you have to manage this file if you \
don't want a client to connect any more (the client name and servername is at the end of each row like name@ubuntu)
cat id_rsa.pub >> authorized_keys2
rm id_rsa.pub
Now we can connect to the remove server without passwords like
ssh -p 22 serverusername@server.com