SSH without password

January 19th, 2012 § 0 comments

Did u think it is awful to enter password everytime while logging into a linux system via ssh?
In another case If you want to ssh from shell script, the password prompt will be an issue.
Here is the way you can get rid of it, But this have high security issue so please don’t use this on public computers.

Disclaimer : I am just sharing my knowledge and I won’t be responsible for any loss of data or anything by using this trick. Use this at your own risk.

Steps to follow are,

  1. Generate ssh public and private keys

    You can easily Generate public and private keys using the command

    ssh-keygen -t rsa

    Just press enter to all the data asked while generating the keys, so that default values will be taken. Make sure you didn’t provide any passphrase for it.

  2. Copy the public key from ~/.ssh/id_rsa.pub

    You can use any text editor to open the file ~/.ssh/id_rsa.pub and copy the key. I prefer to use cat command in terminal.

  3. Login into remote system

    This will be the last time you login into that system using password.

  4. Open the file ~/.ssh/authorized_keys if it exists

    Check whether ~/.ssh/authorized_keys file already exists in the server else you need to create a new one. You can easily create a file using the command

    touch ~/.ssh/authorized_keys
  5. Paste the key and save it

    Paste the key (which you copied earlier) in a new line, at the end of file and save it.

Now please logout from the remote server and try to login again. Now ssh won’t ask for password.

You can try to ssh from shell script also.

Revath S Kumar [RSK]

- Rubyist / JavaScripter - Yeoman Team member - Open source enthusiast - Blogger @ PHPRepo and http://blog.revathskumar.com - Coder @ Whatznear - Google fanboy - jQuery lover

More Posts - Website - Twitter - Facebook - LinkedIn - Pinterest - Google Plus - YouTube

Tagged ,