Wednesday 27 August 2014

ssh login to another server with no login using rsa keys

After you created rsa key, it is time to exchange them with server that you want to connect with no password.

Use this command

root@ubuntus1:~/.ssh# ssh-copy-id -i id_rsa.pub root@192.168.1.2
The authenticity of host '192.168.1.2 (192.168.1.2)' can't be established.
ECDSA key fingerprint is 48:ea:a4:f7:12:15:ca:f0:53:c6:66:44:e8:6b:30:8f.
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 prompt                                                                                        ed now it is to install the new keys
root@192.168.1.2's password:

Number of key(s) added: 1

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


Try to connect!

root@ubuntus1:~/.ssh# ssh 192.168.1.2
Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.5.0-23-generic i686)

 * Documentation:  https://help.ubuntu.com/

  System information as of Wed Aug 27 08:46:14 CEST 2014

  System load:  0.13              Processes:           80
  Usage of /:   65.3% of 2.71GB   Users logged in:     1
  Memory usage: 47%               IP address for eth1: 192.168.1.2
  Swap usage:   1%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

58 packages can be updated.
44 updates are security updates.

New release '14.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

For more information, please see:
http://wiki.ubuntu.com/1204_HWE_EOL

To upgrade to a supported (or longer supported) configuration:

* Upgrade from Ubuntu 12.04 LTS to Ubuntu 14.04 LTS by running:
sudo do-release-upgrade

OR

* Install a newer HWE version by running:
sudo apt-get install linux-generic-lts-trusty linux-image-generic-lts-trusty

and reboot your system.

Last login: Tue Aug 26 14:50:48 2014 from 192.168.1.5
root@ubuntu:~# exit
logout
Connection to 192.168.1.2 closed.
root@ubuntus1:~/.ssh#


As you can see, this is very simple and easy.

No comments: