SSH login without passwords

From assela Pathirana

Jump to: navigation, search



The method described here has inherant problem of sever being vulnarable if the client is compromised. There is no line of defence in between. This arises from the fact that we don't enter a pass-phrase when creating the key-pair. To overcome this issue, without going through the trouble of entering a password (or phrase) at every login, use the application known as Keychain.

Whenever the ssh command is used to login to a remote machine, user needs to provide the remote machines password. While this is an obvious security precaution, it soon becomes a headache once you start to login fifty-times a day to the same, known-and-trusted server from your known-and-trusted client! For such situations, the following is a good approach.


Let's assume the client and server names are

client1 server1

respectively and username in the server (remote machine) is


  1. Create public-private key pair in client1

$ ssh-keygen -t dsa -f ~/.ssh/id_dsa Generating public/private dsa key pair. Enter passphrase (empty for no passphrase): (Don't type anything, just press enter here.) Enter same passphrase again: (Again empty) 52:da:75:66:09:15:5e:cb:6f:a3:xd:39:rd:15:f6:da user@client1

  1. Copy public-key to somewhere in server1
    $ scp ~/.ssh/ user1@server1:~/.ssh/
  2. In the server1, append the public-key for client1 to the authorized-keys file
    cat ~user1/.ssh/ >> ~user1/.ssh/authorized_keys2
  3. Secure the authorized-keys file (otherwise the scheme will not work!) and remove unnecessary files. (in server1)
$ chmod 640 ~user1/.ssh/authorized_keys2 $ rm ~user1/.ssh/ .

Now you should be able to login from client1 to user1@server1 without providing password.

Personal tools