Latest Entries »

Sunday, October 24, 2010

PasswordLess Login with Open-SSH Linux

OpenSSH allows you to login to remote systems and run commands. This is not a new concept for most of linux developers but for who require to perform remote commands without being prompted for a password, this quick tutorial gives just a way. Password less login to remote systems is useful in a lot of ways like copying backups across systems, monitoring multiple systems, trigger various commands, sync repositories etc.

So following is what you would need to do to achieve this. There are plenty of tutorials already for this over the internet since it is not a new concept. I am just documenting it for my personal use and for those who stumble upon my blog.

Step-1 : If you dont have a keypair already, then generate one.
## Leave the options blank and press Enter. 
## It automatically selects the defaults which are good enough

deploy$ ssh-keygen -t rsa

## Output
Generating public/private rsa key pair.
Enter file in which to save the key (/home/deploy/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/deploy/.ssh/id_rsa.
Your public key has been saved in /home/deploy/.ssh/id_rsa.pub.


Step-2 : If you wish to login to a machine called remotehost from localhost then we need to copy this key file to the remotehost.

## The following command will prompt you for the password once
## and copy the key file for you
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remotehost

Great!! You are ready to go and login to the remote host from now onwards without entering your password again. You would need to repeat this password if you are logging from any other machine to remote host. This method is only local to login in from your system. Try doing the following now:-

ssh user@remotehost

Advance users can follow the Debian Guide for further information.

0 comments: