How to Login ssh Without Prompting Password in Linux

February 25, 2011 | By in HOWTOS, LINUX HOWTO
| Reply More

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 (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 create key

$ 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 to ~/.ssh/authorized_keys file of remote machine. To do so you can use the following commands:

# ssh linoxide@ mkdir -p .ssh
# cat .ssh/ | ssh linoxide@ 'cat >> .ssh/authorized_keys'
# ssh linoxide@

The example above is for a user named linoxide and a hostname with the ip address, you will need to change them according to the username and ip address of the server you are using.
It should look like this:

ssh password less

Congratulations! You can now login without using a password.

Tags: ,


Share This :

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.