One way to login without using a password is to use a manually generated public-private key pair to perform the authentication, allowing users or programs to login without having to specify a password. In this case, anyone can produce a matching pair of different keys (public and private). While authentication is based on the private key, the key itself is never transferred through the network during authentication. ssh only verifies whether the same person offering the public key also owns the matching private key.
Generating ssh keys
To generate ssh, keys you can use Linux ssh-keygen command. The ssh-keygen command will generate two keys and store them in two different files. These two files are stored in the user home directory. You can provide your own names for the file or by default it will be stored in id_dsa (private key) and id_dsa.pub (public key) files.
When you create your keys you will be asked for a passphrase. It is used to protect your key and you will be asked for it when you connect via ssh. If you wish password less logins you will need to leave this blank.
Below is the output for ssh-keygen command.
$ ssh-keygen -t dsa
This file is respected only if it is not writable by anything apart from the owner and root, so you need to change the permissions of the ~/.ssh/ directory like so:
$ chmod 750 -R ~/.ssh
Password less login
For no password login, you will need to copy the content of id_dsa.pub to ~/.ssh/authorized_keys file of remote machine. To do so you can use the following commands:
# ssh email@example.com mkdir -p .ssh
# cat .ssh/id_dsa.pub | ssh firstname.lastname@example.org 'cat >> .ssh/authorized_keys'
# ssh email@example.com
The example above is for a user named linoxide and a hostname with the ip address 192.168.1.5, you will need to change them according to the username and ip address of the server you are using.
It should look like this:
Congratulations! You can now login without using a password.