SyntaxHighlighter

Tuesday, December 10, 2013

SSH Login without Password

execute the following from client. Prerequisite user id already created in remote-host.


$ ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubai/.ssh/id_rsa):
Created directory '/home/ubai/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ubai/.ssh/id_rsa.
Your public key has been saved in /home/ubai/.ssh/id_rsa.pub.
The key fingerprint is:
5a:b8:3a:74:f1:f5:3a:aa:40:0d:28:75:9d:9e:83:53 ubai@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
|  . .. .         |
| . o  E          |
|. . .+ .         |
| .  oo=.  .      |
|    ..o+S. .     |
|   .. .+.   .    |
|   ...o    .     |
|    .o    o      |
|    ...... .     |
+-----------------+

$ ssh-copy-id -i ~/.ssh/id_rsa.pub <remote ip / host>

The authenticity of host 'remote-ip (remote-ip)' can't be established.
RSA key fingerprint is c8:b1:2a:bb:1b:a9:f1:eb:0b:5e:a2:06:32:49:3d:bb.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
ubai@remote-ip's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'remote-ip'"
and check to make sure that only the key(s) you wanted were added.




Finally save the passphrase


$ ssh-agent bash
$ ssh-add
Enter passphrase for /home/elyobo/.ssh/id_rsa:
Identity added: /home/ubai/.ssh/id_rsa (/home/ubai/.ssh/id_rsa)