Hello,
Thanks for visiting RvKmR.blogspot.in
In this blog post, I am explaining about configuring passwordless ssh login.
I setup two vms on vagrant environment, name and IP address of respective machines is listed below. I am using image "Ubuntu 14.04.5 LTS "
alpha-ubuntu 10.0.0.10
beta-ubuntu 10.0.0.11
At this stage I am logged in to machine alpha-ubuntu. When I login from alpha-ubuntu to beta-ubuntu, it ll ask for password for respective logging in user. lets check it out.
vagrant@alpha-ubuntu:~$ ssh beta-ubuntu
The authenticity of host 'beta-ubuntu (10.0.0.11)' can't be established.
ECDSA key fingerprint is 06:8d:d6:6d:a1:07:8e:19:2d:1a:2e:5c:b8:0a:0b:f5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'beta-ubuntu' (ECDSA) to the list of known hosts.
vagrant@beta-ubuntu's password:
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-129-generic x86_64)
Last login: Sun Oct 29 09:38:14 2017 from 10.0.0.10
vagrant@beta-ubuntu:~$
Have you seen above ? system beta-ubuntu asks for password of user "vagrant". Now wish to configure system to make it like, when I login from alpha-ubuntu to beta-ubuntu without password prompt. For that purpose you must be aware of Key based login (PKI) process or at least aware about what is Public and private key. If you not aware about it, don't I ll explain it in some other post. for now we ll continue with steps to configure passwordless ssh.
vagrant@beta-ubuntu:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/vagrant/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/vagrant/.ssh/id_rsa.
Your public key has been saved in /home/vagrant/.ssh/id_rsa.pub.
The key fingerprint is:
d6:98:e4:9e:a3:ea:a6:de:7e:80:d4:63:56:6e:24:29 vagrant@beta-ubuntu
The key's randomart image is:
+--[ RSA 2048]----+
| . |
| E o o |
| o = . |
| . = oo + |
| . + o S . |
| . . o . |
| . + |
| .. .. . |
| .o==o. |
+-----------------+
vagrant@beta-ubuntu:~$
Thanks for visiting RvKmR.blogspot.in
In this blog post, I am explaining about configuring passwordless ssh login.
I setup two vms on vagrant environment, name and IP address of respective machines is listed below. I am using image "Ubuntu 14.04.5 LTS "
alpha-ubuntu 10.0.0.10
beta-ubuntu 10.0.0.11
At this stage I am logged in to machine alpha-ubuntu. When I login from alpha-ubuntu to beta-ubuntu, it ll ask for password for respective logging in user. lets check it out.
vagrant@alpha-ubuntu:~$ ssh beta-ubuntu
The authenticity of host 'beta-ubuntu (10.0.0.11)' can't be established.
ECDSA key fingerprint is 06:8d:d6:6d:a1:07:8e:19:2d:1a:2e:5c:b8:0a:0b:f5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'beta-ubuntu' (ECDSA) to the list of known hosts.
vagrant@beta-ubuntu's password:
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-129-generic x86_64)
Last login: Sun Oct 29 09:38:14 2017 from 10.0.0.10
vagrant@beta-ubuntu:~$
Have you seen above ? system beta-ubuntu asks for password of user "vagrant". Now wish to configure system to make it like, when I login from alpha-ubuntu to beta-ubuntu without password prompt. For that purpose you must be aware of Key based login (PKI) process or at least aware about what is Public and private key. If you not aware about it, don't I ll explain it in some other post. for now we ll continue with steps to configure passwordless ssh.
- First step is generate public and private key on alpha-ubuntu. for this we need to use ssh-keygen. you can specify algorithm to encrypt key with option "-t". Or you can leave it to default. This ll asks for file name to save public and private key. I am going with default by just pressing "Enter" button after that it will asks for passphrase. Enter passphrase or you can have nothing. I am going with nothing so pressed "Enter" button.
vagrant@beta-ubuntu:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/vagrant/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/vagrant/.ssh/id_rsa.
Your public key has been saved in /home/vagrant/.ssh/id_rsa.pub.
The key fingerprint is:
d6:98:e4:9e:a3:ea:a6:de:7e:80:d4:63:56:6e:24:29 vagrant@beta-ubuntu
The key's randomart image is:
+--[ RSA 2048]----+
| . |
| E o o |
| o = . |
| . = oo + |
| . + o S . |
| . . o . |
| . + |
| .. .. . |
| .o==o. |
+-----------------+
vagrant@beta-ubuntu:~$
- As you seen, this generated two files "id_rsa" and "id_rsa.pub" at location "/home/vagrant/.ssh/". File " /home/vagrant/.ssh/id_rsa" contains private key for user "vagrant" and file "/home/vagrant/.ssh/id_rsa.pub" contain public key that to be sent while login to another system.
- No we need to copy public key of vagrant user of alpha-ubuntu machine to beta-ubuntu. I am assuming that there is already "vagrant" user on beta-ubuntu machine. We can copy public key with one off ssh utility ssh-copy-id or we can go with our tradition way. I am using ssh utility.vagrant@alpha-ubuntu:~$ ssh-copy-id vagrant@beta_ubu/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
vagrant@beta_ubu's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'vagrant@beta_ubu'"
and check to make sure that only the key(s) you wanted were added.
vagrant@alpha-ubuntu:~$ - Now try login with "ssh 'vagrant@beta_ubu'". vagrant@alpha-ubuntu:~$ ssh 'vagrant@beta_ubu'
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-129-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Sun Oct 29 10:34:37 UTC 2017
System load: 0.25 Processes: 77
Usage of /: 3.6% of 39.34GB Users logged in: 0
Memory usage: 25% IP address for eth0: 10.0.2.15
Swap usage: 0% IP address for eth1: 10.0.0.11
Graph this data and manage this system at:
https://landscape.canonical.com/
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
0 packages can be updated.
0 updates are security updates.
New release '16.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Sun Oct 29 10:33:48 2017 from 10.0.0.10
vagrant@beta-ubuntu:~$ - Hueeeee You see this time beta_ubu not asked for password.
Comments
Post a Comment