27.DevOps:Working with SSH for Ansible usage

ssh

Working with SSH for Ansible usage:
With reference to my blog on Ansible installation on Ubuntu VM,  https://vskumar.blog/2018/05/08/23-devops-how-to-install-ansible-on-ubuntu-linux-vm/

in this blog, I have demonstrated on playing around with ssh among three
ubuntu Vmware Virtual machines.

To use Ansible exercises we need to follow the below pre-requisites with ssh operations.

Pre-requisites for Ansible usage:
https://help.ubuntu.com/community/SSH/OpenSSH/Keys

SSH Keys for Ansible VMs usage:
Before using Ansible we need to make sure the SSH is installed in the
VMs.
I would like to give the steps for this setup as below:

Pre-requisite Step1:
Install OpenSSH on Ubuntu.
Update the package index using the following command:
sudo apt-get update

To install the OpenSSH server application as well as the other related
packages use the command below:
sudo apt-get install openssh-server

Further, you can install the OpenSSH client application using
the following command:
sudo apt-get install openssh-client

Pre-requisite Step2:
Configure OpenSSH on Ubuntu
Before making any changes in OpenSSH configuration,
we need to know how to manage the OpenSSH service on Ubuntu VMs.

How to check ssh version?:
use the command; ssh -V

i) To start the service we can use the following command:
sudo systemctl start sshd.service

ii) To stop the service we can use:
sudo systemctl stop sshd.service

iii) To restart the service we can use:
sudo systemctl restart sshd.service

iv) To check the status of the service we can use:
sudo systemctl status sshd.service

v) If we want to enable the service on system boot we can use:
sudo systemctl enable sshd.service

vi) If we want to disable the service on system boot we can use:
sudo systemctl disable sshd.service

vii) The configuration file for the OpenSSH server application
is in the folder:/etc/ssh/sshd_config
We need to update the default port in this file.
We need to make sure to create a backup of the original configuration before
making any changes:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.orig

We can edit the file by using a text editor of our choice either vi or vim, etc..
The first thing we must do is to change the default SSH listening port.
Open the file and locate the line that specifies the listening port:
Port 22
Change it to your desired port number. Ex: Port 1990

Save the file and close it.
Then restart the service for the changes to take effect.

Note:
After making any changes in the OpenSSH configuration you need to restart the service
for the changes to take effect.

Pre-requisite Step3: Create an SSH key pair
Please note, during Ansible exercise or other DevOps tools, we need to connect to other VMs using SSH keys.

Let us note; the Key-based authentication uses two keys, one “public” key that anyone is allowed
to see.
And another “private” key that only the owner is allowed to see.
To securely communicate using key-based authentication, one needs to create a key pair,
securely store the private key on the computer which we want to log in from [Source machine],
and store the public key on the other Virtual Machine[Target machine] one wants to log in to.
Using key based logins with ssh is generally considered more secure than using plain password logins.

Now, let us see these steps:
1. Generating RSA Keys:
Our first step involves creating a set of RSA keys for use in authentication.
This should be done on the client.
To create our public and private SSH keys we need to use the below commands:
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa

We will be prompted for a location to save the keys, and a passphrase for the keys.
This passphrase will protect our private key while it’s stored on the hard drive:

=== Sample Output ====>
Generating public/private rsa key pair.
Enter file in which to save the key (/home/b/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/b/.ssh/id_rsa.
Your public key has been saved in /home/b/.ssh/id_rsa.pub.
======================>
Note; An SSH key passphrase is a secondary form of security.
You need to remember it while logging the remote machine.
Now, our public key is now available as .ssh/id_rsa.pub in the home directory.

2. Transfer Client Key to Host:
The key we need to transfer to the host is the public one.
If we can log in to a computer over SSH using a password,
we can transfer our RSA key by doing the following from our own computer:
Command format:
====>
ssh-copy-id <username>@<host>
====>
Note: The <username> and <host> should be replaced by our username
and the name of the computer we’re transferring our key to.

TIP on Port# usage:
We cannot specify a port other than the standard port 22 [unless we changed it to
another port# in the target VM]. we can work around this by issuing the
command like this: ssh-copy-id “<username>@<host> -p <port_nr>”.
If we are using the standard port 22, we can ignore this tip.

We can make sure this worked by doing the below command test:
ssh <username>@<host>

We should be prompted for the passphrase for our key:
Enter passphrase for key ‘/home/<user>/.ssh/id_rsa’:
Enter your passphrase, and provided host is configured to allow key-based logins,
we should then be logged in as usual.

 

How to remove the existing SSH from Ubuntu ?
If we have already ssh we can use the below steps to remove and
get the latest setup.

Step1: Stop SSH service before uninstalling it.
service ssh stop

Step2: Now, we need to Uninstall and remove the ssh package from the machine by using the below
apt-get command.

apt-get purge openssh-server

Now you can check its status using ssh -VM
If it is not there you should not get the version.

Please note my VMs Ips,where i will apply some exercises timely:

IP of Ans-ControlMachine:
192.168.116.132

IP of VM1:
192.168.116.134

IP of VM2:
192.168.116.135

IP of VM3:
192.168.116.133

The machine names are prompted in CLI.
I am using these four Virtual machines on Vmware environment with player as well as Workstation.

I have played around with SSH among these machines.
I have copied most of the screen outputs in this content.

Removing SSH from one Virtual machine for installating procedure testing:
I have preloaded SSH earlier.
I am purging SSH in one Virtual machine to demonstrate the exercise.
And below I have copied the screen outputs also.

==== Screen outputs for Ans-ControlMachine =====>
=== Removing SSH from Ans-ControlMachine=========>
vskumar@ubuntu:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016
vskumar@ubuntu:~$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~$ service ssh stop
Failed to stop ssh.service: Unit ssh.service not loaded.
vskumar@ubuntu:~$ service ssh status
● ssh.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
vskumar@ubuntu:~$
vskumar@ubuntu:~$ apt-get -purge openssh-server
E: Command line option ‘p’ [from -purge] is not understood in combination with the other options.
vskumar@ubuntu:~$ apt-get purge remove openssh-server
E: Could not open lock file /var/lib/dpkg/lock – open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
vskumar@ubuntu:~$ sudo apt-get purge remove openssh-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package remove
vskumar@ubuntu:~$ sudo apt-get purge openssh-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package ‘openssh-server’ is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 432 not upgraded.

vskumar@ubuntu:~$ sudo apt-get purge openssh-client
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be REMOVED:
openssh-client* snapd* ubuntu-core-launcher*
0 upgraded, 0 newly installed, 3 to remove and 429 not upgraded.
After this operation, 61.7 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database … 176110 files and directories currently installed.)
Removing ubuntu-core-launcher (2.25) …
Removing snapd (2.25) …
Warning: Stopping snapd.service, but it can still be activated by:
snapd.socket
Purging configuration files for snapd (2.25) …
Final directory cleanup
Discarding preserved snap namespaces
umount: /run/snapd/ns/*.mnt: mountpoint not found
umount: /run/snapd/ns/: mountpoint not found
Removing extra snap-confine apparmor rules
Removing snapd state
Removing openssh-client (1:7.2p2-4ubuntu2.2) …
Purging configuration files for openssh-client (1:7.2p2-4ubuntu2.2) …
Processing triggers for man-db (2.7.5-1) …

vskumar@ubuntu:~$
s for man-db (2.7.5-1) …
vskumar@ubuntu:~$
vskumar@ubuntu:~$ ssh -V
bash: /usr/bin/ssh: No such file or directory
vskumar@ubuntu:~$
== So we have completely removed the SSH ====>
=== from Ans-ControlMachine=========>

Installing SSH into Ans-ControlMachine:

Now, let me install the SSH server and client also.
Step1:
Let update the packages.
sudo apt-get update

== Output =======>
vskumar@ubuntu:~$ sudo apt-get update

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [67.7 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 DEP-11 Metadata [319 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/main DEP-11 64×64 Icons [72.6 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [107 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe DEP-11 64×64 Icons [147 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu xenial-updates/main DEP-11 64×64 Icons [226 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [246 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe DEP-11 64×64 Icons [331 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,964 B]
Get:14 http://us.archive.ubuntu.com/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,324 B]
Get:15 http://us.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [5,088 B]
Fetched 1,853 kB in 11s (168 kB/s)
Reading package lists… Done
vskumar@ubuntu:~$
============>

Step2: Installing server
Now, we will use the below command to install ssh srver:
sudo apt-get install openssh-server

==== Screen output ======>
vskumar@ubuntu:~$ sudo apt-get install openssh-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
ncurses-term openssh-client openssh-sftp-server ssh-import-id
Suggested packages:
ssh-askpass libpam-ssh keychain monkeysphere rssh molly-guard
The following NEW packages will be installed:
ncurses-term openssh-client openssh-server openssh-sftp-server ssh-import-id
0 upgraded, 5 newly installed, 0 to remove and 429 not upgraded.
Need to get 1,222 kB of archives.
After this operation, 8,917 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-client amd64 1:7.2p2-4ubuntu2.4 [589 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ncurses-term all 6.0+20160213-1ubuntu1 [249 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-sftp-server amd64 1:7.2p2-4ubuntu2.4 [38.7 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-server amd64 1:7.2p2-4ubuntu2.4 [335 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ssh-import-id all 5.5-0ubuntu1 [10.2 kB]
Fetched 1,222 kB in 7s (162 kB/s)
Preconfiguring packages …
Selecting previously unselected package openssh-client.
(Reading database … 176023 files and directories currently installed.)
Preparing to unpack …/openssh-client_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-client (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package ncurses-term.
Preparing to unpack …/ncurses-term_6.0+20160213-1ubuntu1_all.deb …
Unpacking ncurses-term (6.0+20160213-1ubuntu1) …
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack …/openssh-sftp-server_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-sftp-server (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package openssh-server.
Preparing to unpack …/openssh-server_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-server (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package ssh-import-id.
Preparing to unpack …/ssh-import-id_5.5-0ubuntu1_all.deb …
Unpacking ssh-import-id (5.5-0ubuntu1) …
Processing triggers for man-db (2.7.5-1) …
Processing triggers for ufw (0.35-0ubuntu2) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Setting up openssh-client (1:7.2p2-4ubuntu2.4) …
Setting up ncurses-term (6.0+20160213-1ubuntu1) …
Setting up openssh-sftp-server (1:7.2p2-4ubuntu2.4) …
Setting up openssh-server (1:7.2p2-4ubuntu2.4) …
Creating SSH2 RSA key; this may take some time …
2048 SHA256:3yMAIuH8WhE4tf0kwEqrBHo7gxj3nYq/RTXhYMrpz/s root@ubuntu (RSA)
Creating SSH2 DSA key; this may take some time …
1024 SHA256:HoY3UATMD48l8tOWSWQcJWtwK+s98j7WpD7WGEPsbVo root@ubuntu (DSA)
Creating SSH2 ECDSA key; this may take some time …
256 SHA256:sIDDAzkiGiTCzpGHOTEU3QbG/oNn4DNvXxHtm7kzAZ4 root@ubuntu (ECDSA)
Creating SSH2 ED25519 key; this may take some time …
256 SHA256:hGlI7mLNIGbU2bs/igS1YZrNwxxCvFpszZxOCAOozGk root@ubuntu (ED25519)
Setting up ssh-import-id (5.5-0ubuntu1) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Processing triggers for ufw (0.35-0ubuntu2) …
vskumar@ubuntu:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
vskumar@ubuntu:~$
=======================>

Step3: install client
We can try to install the OpenSSH client application using
the following command:
sudo apt-get install openssh-client

==== Screen output =====================>
vskumar@ubuntu:~$
vskumar@ubuntu:~$ sudo apt-get install openssh-client
Reading package lists… Done
Building dependency tree
Reading state information… Done
openssh-client is already the newest version (1:7.2p2-4ubuntu2.4).
openssh-client set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 429 not upgraded.
vskumar@ubuntu:~$
=== It is installed along with server ====>

Step4:
Now, let us check the status:

=== Status of SSH server ===>
vskumar@ubuntu:~$ sudo systemctl status sshd.service
● ssh.service – OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
Active: active (running) since Sat 2018-05-26 05:21:18 PDT; 6min ago
Main PID: 4645 (sshd)
CGroup: /system.slice/ssh.service
└─4645 /usr/sbin/sshd -D

May 26 05:21:17 ubuntu systemd[1]: Starting OpenBSD Secure Shell server…
May 26 05:21:17 ubuntu sshd[4645]: Server listening on 0.0.0.0 port 22.
May 26 05:21:17 ubuntu sshd[4645]: Server listening on :: port 22.
May 26 05:21:18 ubuntu systemd[1]: Started OpenBSD Secure Shell server.
lines 1-11/11 (END)
vskumar@ubuntu:~$
============================>

Generating RSA Keys:
Step1:
To create our public and private SSH keys we need to use the below commands:
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa

=== Screen output ===>
vskumar@ubuntu:~$ ls
Desktop Downloads Music Public Videos
Documents examples.desktop Pictures Templates
vskumar@ubuntu:~$ ls -la
total 116
drwxr-xr-x 17 vskumar vskumar 4096 May 26 05:30 .
drwxr-xr-x 3 root root 4096 Nov 22 2017 ..
-rw——- 1 vskumar vskumar 524 Mar 6 18:06 .bash_history
-rw-r–r– 1 vskumar vskumar 220 Nov 22 2017 .bash_logout
-rw-r–r– 1 vskumar vskumar 3771 Nov 22 2017 .bashrc
drwx—— 13 vskumar vskumar 4096 May 26 04:45 .cache
drwx—— 14 vskumar vskumar 4096 Nov 22 2017 .config
drwxr-xr-x 2 vskumar vskumar 4096 Nov 22 2017 Desktop
-rw-r–r– 1 vskumar vskumar 25 Nov 22 2017 .dmrc
drwxr-xr-x 2 vskumar vskumar 4096 Nov 22 2017 Documents
drwxr-xr-x 2 vskumar vskumar 4096 Nov 22 2017 Downloads
-rw-r–r– 1 vskumar vskumar 8980 Nov 22 2017 examples.desktop
drwx—— 2 vskumar vskumar 4096 Dec 22 21:36 .gconf
drwx—— 3 vskumar vskumar 4096 May 26 04:42 .gnupg
-rw——- 1 vskumar vskumar 3498 May 26 04:42 .ICEauthority
drwx—— 3 vskumar vskumar 4096 Nov 22 2017 .local
drwx—— 4 vskumar vskumar 4096 Nov 22 2017 .mozilla
drwxr-xr-x 2 vskumar vskumar 4096 Nov 22 2017 Music
drwxr-xr-x 2 vskumar vskumar 4096 Nov 22 2017 Pictures
-rw-r–r– 1 vskumar vskumar 655 Nov 22 2017 .profile
drwxr-xr-x 2 vskumar vskumar 4096 Nov 22 2017 Public
drwxrwxr-x 2 vskumar vskumar 4096 May 26 05:30 .ssh
-rw-r–r– 1 vskumar vskumar 0 Nov 22 2017 .sudo_as_admin_successful
drwxr-xr-x 2 vskumar vskumar 4096 Nov 22 2017 Templates
drwxr-xr-x 2 vskumar vskumar 4096 Nov 22 2017 Videos
-rw——- 1 vskumar vskumar 51 May 26 04:42 .Xauthority
-rw——- 1 vskumar vskumar 82 May 26 04:42 .xsession-errors
-rw——- 1 vskumar vskumar 82 May 26 03:11 .xsession-errors.old
vskumar@ubuntu:~$
vskumar@ubuntu:~$ chmod 700 ~/.ssh
I copied on the below line:
drwx—— 2 vskumar vskumar 4096 May 26 05:30 .ssh
The rights are changed.
======================>

=========================>
vskumar@ubuntu:~$
vskumar@ubuntu:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/vskumar/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/vskumar/.ssh/id_rsa.
Your public key has been saved in /home/vskumar/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:jLVDx+RqfC+3lo3qcajm+gcHO+44+h/cfTDDLHtsEAg vskumar@ubuntu
The key’s randomart image is:
+—[RSA 2048]—-+
| E . |
| . = |
| + = |
| *.+ + |
| . So+ * |
| o++.O + |
| .o+* O+. |
| ..oo.B+o. |
| .o+O*ooo. |
+—-[SHA256]—–+
vskumar@ubuntu:~$
=== I have given the pwd for passphrase ====>

Step2: Transfer Client Key to Host
ssh-copy-id <username>@<host>
I will try with VM1.
==== Copting ssh id to VM1 ====>
== From Ans-ControlMachine ====>
vskumar@ubuntu:~/.ssh$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~/.ssh$ ls
id_rsa id_rsa.pub known_hosts
vskumar@ubuntu:~/.ssh$ ssh ssh-copy-id vskumar@192.168.116.134
ssh: Could not resolve hostname ssh-copy-id: Name or service not known
vskumar@ubuntu:~/.ssh$ sudo ssh-copy-id vskumar@192.168.116.134
[sudo] password for vskumar:
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/home/vskumar/.ssh/id_rsa.pub”
The authenticity of host ‘192.168.116.134 (192.168.116.134)’ can’t be established.
ECDSA key fingerprint is SHA256:ZPPT6yQv8nAC1A6cDkeIssDYiim81f4/88I+NNVm1Iw.
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
vskumar@192.168.116.134’s password:

Number of key(s) added: 1

Now try logging into the machine, with: “ssh ‘vskumar@192.168.116.134′”
and check to make sure that only the key(s) you wanted were added.

vskumar@ubuntu:~/.ssh$

==== Copied ssh key to VM1 ===>

======From VM1 =====>
vskumar@VM1:~$
vskumar@VM1:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016
vskumar@VM1:~$ service ssh stop
Failed to stop ssh.service: Unit ssh.service not loaded.
vskumar@VM1:~$ apt-get -purge openssh-server
E: Command line option ‘p’ [from -purge] is not understood in combination with the other options.
vskumar@VM1:~$ sudo apt-get -purge openssh-server
[sudo] password for vskumar:
E: Command line option ‘p’ [from -purge] is not understood in combination with the other options.
vskumar@VM1:~$ sudo apt-get purge openssh-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package ‘openssh-server’ is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 432 not upgraded.
vskumar@VM1:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016
vskumar@VM1:~$ sudo apt-get purge openssh-client
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be REMOVED:
openssh-client* snapd* ubuntu-core-launcher*
0 upgraded, 0 newly installed, 3 to remove and 429 not upgraded.
After this operation, 61.7 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database … 176110 files and directories currently installed.)
Removing ubuntu-core-launcher (2.25) …
Removing snapd (2.25) …
Warning: Stopping snapd.service, but it can still be activated by:
snapd.socket
Purging configuration files for snapd (2.25) …
Final directory cleanup
Discarding preserved snap namespaces
umount: /run/snapd/ns/*.mnt: mountpoint not found
umount: /run/snapd/ns/: mountpoint not found
Removing extra snap-confine apparmor rules
Removing snapd state
Removing openssh-client (1:7.2p2-4ubuntu2.2) …
Purging configuration files for openssh-client (1:7.2p2-4ubuntu2.2) …
Processing triggers for man-db (2.7.5-1) …
vskumar@VM1:~$
vskumar@VM1:~$ ssh -V
bash: /usr/bin/ssh: No such file or directory
vskumar@VM1:~$

vskumar@VM1:~$ sudo apt-get update
0% [Working]
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Hit:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [67.7 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [783 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/main DEP-11 64×64 Icons [72.6 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [107 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe DEP-11 64×64 Icons [147 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [718 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 DEP-11 Metadata [319 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu xenial-updates/main DEP-11 64×64 Icons [226 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [631 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [577 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [246 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe DEP-11 64×64 Icons [331 kB]
Get:17 http://us.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,964 B]
Get:18 http://us.archive.ubuntu.com/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,324 B]
Get:19 http://us.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [5,088 B]
Fetched 4,562 kB in 24s (187 kB/s)
Reading package lists… Done
vskumar@VM1:~$

vskumar@VM1:~$
vskumar@VM1:~$ sudo apt-get install openssh-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
ncurses-term openssh-client openssh-sftp-server ssh-import-id
Suggested packages:
ssh-askpass libpam-ssh keychain monkeysphere rssh molly-guard
The following NEW packages will be installed:
ncurses-term openssh-client openssh-server openssh-sftp-server ssh-import-id
0 upgraded, 5 newly installed, 0 to remove and 429 not upgraded.
Need to get 1,222 kB of archives.
After this operation, 8,917 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-client amd64 1:7.2p2-4ubuntu2.4 [589 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ncurses-term all 6.0+20160213-1ubuntu1 [249 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-sftp-server amd64 1:7.2p2-4ubuntu2.4 [38.7 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-server amd64 1:7.2p2-4ubuntu2.4 [335 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ssh-import-id all 5.5-0ubuntu1 [10.2 kB]
Fetched 1,222 kB in 7s (160 kB/s)
Preconfiguring packages …
Selecting previously unselected package openssh-client.
(Reading database … 176023 files and directories currently installed.)
Preparing to unpack …/openssh-client_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-client (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package ncurses-term.
Preparing to unpack …/ncurses-term_6.0+20160213-1ubuntu1_all.deb …
Unpacking ncurses-term (6.0+20160213-1ubuntu1) …
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack …/openssh-sftp-server_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-sftp-server (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package openssh-server.
Preparing to unpack …/openssh-server_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-server (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package ssh-import-id.
Preparing to unpack …/ssh-import-id_5.5-0ubuntu1_all.deb …
Unpacking ssh-import-id (5.5-0ubuntu1) …
Processing triggers for man-db (2.7.5-1) …
Processing triggers for ufw (0.35-0ubuntu2) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Setting up openssh-client (1:7.2p2-4ubuntu2.4) …
Setting up ncurses-term (6.0+20160213-1ubuntu1) …
Setting up openssh-sftp-server (1:7.2p2-4ubuntu2.4) …
Setting up openssh-server (1:7.2p2-4ubuntu2.4) …
Creating SSH2 RSA key; this may take some time …
2048 SHA256:4efQhtH82rrRfTvvYxt3Wu7lJg0HJcW66yEi6WaTN+c root@VM1 (RSA)
Creating SSH2 DSA key; this may take some time …
1024 SHA256:fGZ3vX279MRTXsRhzYyHSPIwVv7ge2/WRQmh+SHlIZo root@VM1 (DSA)
Creating SSH2 ECDSA key; this may take some time …
256 SHA256:ZPPT6yQv8nAC1A6cDkeIssDYiim81f4/88I+NNVm1Iw root@VM1 (ECDSA)
Creating SSH2 ED25519 key; this may take some time …
256 SHA256:5rZGM1Q0vbVD82kcvKS4NdtzCGgDIaiEjL+C01+iJgU root@VM1 (ED25519)
Setting up ssh-import-id (5.5-0ubuntu1) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Processing triggers for ufw (0.35-0ubuntu2) …
vskumar@VM1:~$
vskumar@VM1:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
vskumar@VM1:~$

==========================>

 

===Connecting to >
vskumar@VM1:~$ ssh vskumar@Ans-ControlMachine
ssh: Could not resolve hostname ans-controlmachine: Name or service not known
vskumar@VM1:~$ ssh vskumar@192.168.116.132
The authenticity of host ‘192.168.116.132 (192.168.116.132)’ can’t be established.
ECDSA key fingerprint is SHA256:sIDDAzkiGiTCzpGHOTEU3QbG/oNn4DNvXxHtm7kzAZ4.
Are you sure you want to continue connecting (yes/no)? y
Please type ‘yes’ or ‘no’: yes
Warning: Permanently added ‘192.168.116.132’ (ECDSA) to the list of known hosts.
vskumar@192.168.116.132’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

 

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

vskumar@ubuntu:~$

vskumar@ubuntu:~$ pwd
/home/vskumar
vskumar@ubuntu:~$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~$ exit
logout
Connection to 192.168.116.132 closed.
vskumar@VM1:~$ cat /etc/hostname
VM1
vskumar@VM1:~$
==== Connected from VM1 to ======>
==== Ans-ControlMachine and exit ======>

I am connecting to VM1 from Ans-ControlMachine through ssh.

== Connecting to VM1 from ==>
====Ans-ControlMachine =====>
vskumar@ubuntu:~/.ssh$ ssh vskumar@192.168.116.134
The authenticity of host ‘192.168.116.134 (192.168.116.134)’ can’t be established.
ECDSA key fingerprint is SHA256:ZPPT6yQv8nAC1A6cDkeIssDYiim81f4/88I+NNVm1Iw.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.116.134’ (ECDSA) to the list of known hosts.
vskumar@192.168.116.134’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

 

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

vskumar@VM1:~$ cat /etc/hostname
VM1
vskumar@VM1:~$
vskumar@VM1:~$
vskumar@VM1:~$ exit
logout
Connection to 192.168.116.134 closed.
vskumar@ubuntu:~/.ssh$
vskumar@ubuntu:~/.ssh$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~/.ssh$
======= Exit from VM1 And back ====>
==== to Ans-ControlMachine ====>

 

=== Connecting from VM1 to VM2 ===>
== Connecting in the same SSH ====>
== From VM1 to Ans-ControlMachine ====>
== You can play around with ssh ====>
== Across VMs by using IPs ========>
vskumar@VM2:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016
vskumar@VM2:~$ sudo ssh vskumar@VM1
[sudo] password for vskumar:
ssh: Could not resolve hostname vm1: Name or service not known
vskumar@VM2:~$ sudo ssh vskumar@192.168.116.134
The authenticity of host ‘192.168.116.134 (192.168.116.134)’ can’t be established.
ECDSA key fingerprint is SHA256:ZPPT6yQv8nAC1A6cDkeIssDYiim81f4/88I+NNVm1Iw.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.116.134’ (ECDSA) to the list of known hosts.
vskumar@192.168.116.134’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

Last login: Sat May 26 06:00:10 2018 from 192.168.116.132
vskumar@VM1:~$ cat /etc/hostname
VM1
vskumar@VM1:~$ ssh vskumar@192.168.116.132
vskumar@192.168.116.132’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

Last login: Sat May 26 05:55:36 2018 from 192.168.116.134
vskumar@ubuntu:~$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~$
vskumar@ubuntu:~$ exit
logout
Connection to 192.168.116.132 closed.
vskumar@VM1:~$

vskumar@VM1:~$ exit
logout
Connection to 192.168.116.134 closed.
vskumar@VM2:~$ cat /etc/hostname
VM2
vskumar@VM2:~$
== We have played around 3 VMs ===>
=== With SSH =====================>

 

=== Connecting from VM2 ===>
==== tO Ans-ControlMachine===>
vskumar@VM2:~$ ssh vskumar@192.168.116.132
The authenticity of host ‘192.168.116.132 (192.168.116.132)’ can’t be established.
ECDSA key fingerprint is SHA256:sIDDAzkiGiTCzpGHOTEU3QbG/oNn4DNvXxHtm7kzAZ4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.116.132’ (ECDSA) to the list of known hosts.
vskumar@192.168.116.132’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

Last login: Sat May 26 06:05:18 2018 from 192.168.116.134
vskumar@ubuntu:~$
vskumar@ubuntu:~$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~$
vskumar@ubuntu:~$ exit
logout
Connection to 192.168.116.132 closed.
vskumar@VM2:~$
==== Conneted from VM2 ==>

=== Removing ssh from VM2 ====>
== To have clean files ========>
vskumar@VM2:~$ sudo apt-get purge openssh-client
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be REMOVED:
openssh-client* snapd* ubuntu-core-launcher*
0 upgraded, 0 newly installed, 3 to remove and 429 not upgraded.
After this operation, 61.7 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database … 176110 files and directories currently installed.)
Removing ubuntu-core-launcher (2.25) …
Removing snapd (2.25) …
Warning: Stopping snapd.service, but it can still be activated by:
snapd.socket
Purging configuration files for snapd (2.25) …
Final directory cleanup
Discarding preserved snap namespaces
umount: /run/snapd/ns/*.mnt: mountpoint not found
umount: /run/snapd/ns/: mountpoint not found
Removing extra snap-confine apparmor rules
Removing snapd state
Removing openssh-client (1:7.2p2-4ubuntu2.2) …
Purging configuration files for openssh-client (1:7.2p2-4ubuntu2.2) …
Processing triggers for man-db (2.7.5-1) …
vskumar@VM2:~$
vskumar@VM2:~$ ssh -V
bash: /usr/bin/ssh: No such file or directory
vskumar@VM2:~$
===== SSH is removed in VM2 ====>

=== Installing ssh in VM2 ====>
vskumar@VM2:~$ sudo apt-get install openssh-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
ncurses-term openssh-client openssh-sftp-server ssh-import-id
Suggested packages:
ssh-askpass libpam-ssh keychain monkeysphere rssh molly-guard
The following NEW packages will be installed:
ncurses-term openssh-client openssh-server openssh-sftp-server ssh-import-id
0 upgraded, 5 newly installed, 0 to remove and 429 not upgraded.
Need to get 633 kB/1,222 kB of archives.
After this operation, 8,917 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ncurses-term all 6.0+20160213-1ubuntu1 [249 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-sftp-server amd64 1:7.2p2-4ubuntu2.4 [38.7 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-server amd64 1:7.2p2-4ubuntu2.4 [335 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ssh-import-id all 5.5-0ubuntu1 [10.2 kB]
Fetched 633 kB in 34s (18.5 kB/s)
Preconfiguring packages …
Selecting previously unselected package openssh-client.
(Reading database … 176023 files and directories currently installed.)
Preparing to unpack …/openssh-client_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-client (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package ncurses-term.
Preparing to unpack …/ncurses-term_6.0+20160213-1ubuntu1_all.deb …
Unpacking ncurses-term (6.0+20160213-1ubuntu1) …
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack …/openssh-sftp-server_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-sftp-server (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package openssh-server.
Preparing to unpack …/openssh-server_1%3a7.2p2-4ubuntu2.4_amd64.deb …
Unpacking openssh-server (1:7.2p2-4ubuntu2.4) …
Selecting previously unselected package ssh-import-id.
Preparing to unpack …/ssh-import-id_5.5-0ubuntu1_all.deb …
Unpacking ssh-import-id (5.5-0ubuntu1) …
Processing triggers for man-db (2.7.5-1) …
Processing triggers for ufw (0.35-0ubuntu2) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Setting up openssh-client (1:7.2p2-4ubuntu2.4) …
Setting up ncurses-term (6.0+20160213-1ubuntu1) …
Setting up openssh-sftp-server (1:7.2p2-4ubuntu2.4) …
Setting up openssh-server (1:7.2p2-4ubuntu2.4) …
Creating SSH2 RSA key; this may take some time …
2048 SHA256:JzaY4P+pXshET4rzo/+nkNxGxWe9Hl2Vljd5OV9upko root@VM2 (RSA)
Creating SSH2 DSA key; this may take some time …
1024 SHA256:M49R3FKLVlxGFRw8Caf+s1ktna9h3Ak5Ls93+TyBrac root@VM2 (DSA)
Creating SSH2 ECDSA key; this may take some time …
256 SHA256:/HtM2RyrOSeFO01WW3d1S5fcB9mBM7MApniY54Nq4k4 root@VM2 (ECDSA)
Creating SSH2 ED25519 key; this may take some time …
256 SHA256:lbmYMsRLrCR23898dlX4TidNFYkasm3w/lpyl0oZXfg root@VM2 (ED25519)
Setting up ssh-import-id (5.5-0ubuntu1) …
Processing triggers for systemd (229-4ubuntu19) …
Processing triggers for ureadahead (0.100.0-19) …
Processing triggers for ufw (0.35-0ubuntu2) …
vskumar@VM2:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
vskumar@VM2:~$
== Now VM2 has the complete ssh =====>

=== Now let me connect to ===>
====Ans-ControlMachine ======>
== From VM2 =================>

vskumar@VM2:~$ sudo ssh vskumar@192.168.116.132
The authenticity of host ‘192.168.116.132 (192.168.116.132)’ can’t be established.
ECDSA key fingerprint is SHA256:sIDDAzkiGiTCzpGHOTEU3QbG/oNn4DNvXxHtm7kzAZ4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.116.132’ (ECDSA) to the list of known hosts.
vskumar@192.168.116.132’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

Last login: Sat May 26 06:58:14 2018 from 192.168.116.135
vskumar@ubuntu:~$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~$
vskumar@ubuntu:~$ exit
logout
Connection to 192.168.116.132 closed.
vskumar@VM2:~$
== Connected and exited ====>

=== Now let me connect to ===>
====From Ans-ControlMachine ======>
==== TO VM2 =================>
vskumar@ubuntu:~/.ssh$ ssh vskumar@192.168.116.135
The authenticity of host ‘192.168.116.135 (192.168.116.135)’ can’t be established.
ECDSA key fingerprint is SHA256:/HtM2RyrOSeFO01WW3d1S5fcB9mBM7MApniY54Nq4k4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.116.135’ (ECDSA) to the list of known hosts.
vskumar@192.168.116.135’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

vskumar@VM2:~$ cat /etc/hostname
VM2
vskumar@VM2:~$
vskumar@VM2:~$ exit
logout
Connection to 192.168.116.135 closed.
vskumar@ubuntu:~/.ssh$
===== Connected to VM2 and exited ===>

== SSh key added in VM2 ===>
====From Ans-ControlMachine ======>
vskumar@ubuntu:~/.ssh$
vskumar@ubuntu:~/.ssh$ ssh ssh-copy-id vskumar@192.168.116.135
ssh: Could not resolve hostname ssh-copy-id: Name or service not known
vskumar@ubuntu:~/.ssh$ sudo ssh-copy-id vskumar@192.168.116.135
[sudo] password for vskumar:
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/home/vskumar/.ssh/id_rsa.pub”
The authenticity of host ‘192.168.116.135 (192.168.116.135)’ can’t be established.
ECDSA key fingerprint is SHA256:/HtM2RyrOSeFO01WW3d1S5fcB9mBM7MApniY54Nq4k4.
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
vskumar@192.168.116.135’s password:

Number of key(s) added: 1

Now try logging into the machine, with: “ssh ‘vskumar@192.168.116.135′”
and check to make sure that only the key(s) you wanted were added.

vskumar@ubuntu:~/.ssh$
===== So now, we have made correct ssh connection ====>
=== with VM2 also ============================>

Now, let us try with VM3 as below:

=== Status of VM3 ====>
vskumar@VM3:~$ cat /etc/hostname
VM3
vskumar@VM3:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016
vskumar@VM3:~$
vskumar@VM3:~$ ssh vskumar@192.168.116.135
The authenticity of host ‘192.168.116.135 (192.168.116.135)’ can’t be established.
ECDSA key fingerprint is SHA256:/HtM2RyrOSeFO01WW3d1S5fcB9mBM7MApniY54Nq4k4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.116.135’ (ECDSA) to the list of known hosts.
vskumar@192.168.116.135’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

Last login: Sat May 26 07:13:50 2018 from 192.168.116.132
vskumar@VM2:~$ cat /etc/hostname
VM2
vskumar@VM2:~$
vskumar@VM2:~$ ssh vskumar@192.168.116.132
vskumar@192.168.116.132’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

Last login: Sat May 26 07:13:07 2018 from 192.168.116.132
vskumar@ubuntu:~$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~$
vskumar@ubuntu:~$ exit
logout
Connection to 192.168.116.132 closed.
vskumar@VM2:~$
vskumar@VM2:~$ exit
logout
Connection to 192.168.116.135 closed.
vskumar@VM3:~$
vskumar@VM3:~$ ssh vskumar@192.168.116.132
The authenticity of host ‘192.168.116.132 (192.168.116.132)’ can’t be established.
ECDSA key fingerprint is SHA256:sIDDAzkiGiTCzpGHOTEU3QbG/oNn4DNvXxHtm7kzAZ4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.116.132’ (ECDSA) to the list of known hosts.
vskumar@192.168.116.132’s password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-28-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

437 packages can be updated.
251 updates are security updates.

Last login: Sat May 26 07:35:04 2018 from 192.168.116.135
vskumar@ubuntu:~$ cat /etc/hostname
Ans-ControlMachine
vskumar@ubuntu:~$ exit
logout
Connection to 192.168.116.132 closed.
vskumar@VM3:~$
== So, we could connect from VM3 ====>
=== To all 3 other VMs ==============>
== The issues is resolved for ssh in VM3 ===>

Now, we are ready to use these ssh connection made machines for Ansible future exercises.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s