/* Ajith - Syntax Higlighter - End ----------------------------------------------- */

4.05.2012

Connecting via SSH without password prompt

SSH is the common way to connect remote machines these days. Almost all kinds of applications use SSH in background for communicating with end machines.

But sometimes typing password repeatedly for establishing a SSH connection with the trusted end machine is quite daunting task.

Let us see how to automate the things in 3 simple steps where we can ssh to "user@host" without asking a password every time. Replace user with the username and host with the remote machine ip-address or hostname. For E.g. john@192.168.245.129

NOTE: Only do this with trusted machines.

  1. Login to your local machine from which you want to ssh to remote machine. Go to your .ssh folder.
  2. cd ~/.ssh

  3. Check if you have a 'id_rsa.pub' (or 'id_dsa.pub') file in .ssh folder. If not, try below command:
  4. ssh-keygen -t rsa 

    To make it simple just keep on pressing the ENTER key a bunch of times, even when it asks for a password.

  5. Run ssh-copy-id
  6. ssh-copy-id -i id_rsa.pub user@host 
    If it asks for remote machine password then provide it so that it can create a security key successfully so that you dont need to remember password everytime.

Its done .. Now you can ssh to user@host without being prompted for password.

2 comments :

  1. I was working for a while on this with no progress but your article saved me....Thank you so much!! :)

    ReplyDelete
  2. It's a life saviour!!
    I work on more than 30 servers with 11 application users. Now using your article, I configured it and its working absolutely fine. Thanks a lot!!

    ReplyDelete

Your comments are moderated