Tuesday, January 12, 2010

Fast SSH login (without passwords)

This simple tutorial has been extracted from "Peters's Blog". To avoid retype of password in ssh remote connections, follow the next steps:

  1. install openssh on client and server
  2. create ssh key using:
    ssh-keygen -t dsa
  3. Log into server using sftp
  4. copy the file id_dsa.pub (generated in the client) to the server
  5. on the server, merge contents of (client) id_dsa.pub with ~/.ssh/authorized_keys2
  6. From client, try logging in using ssh or sftp. Key should be accepted.

2 comments:

  1. An additional step to consider is to generate config file to make shortcuts for the ssh command. Suppose you want to access the following server

    www.example.com

    which allows ssh connections in the port 1000 for a user "testuser". Assuming that the steps in the post have been executed, simply create the file "config" in the directory .ssh with the following contents:

    Host example
    HostName www.example.com
    User testuser
    Port 1000

    Now, by typing in the console

    ssh example

    You will be directly connected to the ssh server without any password prompting (if you have set up the steps mentioned above in the post)

    ReplyDelete
  2. Thanks for that Miquel, I didn't know that latter trick.

    ReplyDelete