So friends, in this particular video, what we're going to do is set up SSH keys
so that we can
authenticate into our managed devices, that is going to be the blue box and
yellow box
from the Ansible control node without having to enter any passwords. And now it
's not just that.
What we want to do is on each of our machines, that is the Ansible control node
, as well as
the managed devices, we want to create a user called Ansible. And this is going
to be a dedicated
user account for Ansible to operate. Now it's not absolutely essential that you WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
user account for Ansible to operate. Now it's not absolutely essential that you
create
a Ansible user, but realistically for managing things such as security, having
this dedicated
account really does keep things a lot cleaner. So the very first thing is we
will create that
Ansible account, we'll say it's sudo user ads dash M, and I will just say Ans
ible. And then I
will say it's sudo pass wd and then specify the account I want to create the
password for,
which is Ansible. If I hit enter, now what I'm going to do is specify the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
which is Ansible. If I hit enter, now what I'm going to do is specify the
password that I want
to use for the Ansible account. Now just to keep things really, really simple,
I will alter
as call the password Ansible. Okay, once again, not exactly best practices, we
can see we're getting
a warning that this is a bad password, but nevertheless, let's just stick with
the word
Ansible again. Okay, so we now have created this Ansible user, let's do the
same thing on the
other two machines. So I'm here on the blue box, let me just say sudo user ad
dash m Ansible,
type in the password of password one for super user privileges. And now I will WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
type in the password of password one for super user privileges. And now I will
create the
password for the Ansible user so sudo pass wd Ansible. Again, the password is
simply going to be the
word Ansible. And let's just confirm that and to enter. Now let's go to the
yellow box. Once again,
let's just create the Ansible user and we'll give the Ansible user password of
Ansible and once
again just confirm that password. Now what I also want to do is to give the Ans
ible user account
access to the sudo command without having to type a password. Once again, we
will handle this a
little bit different in a real environment, but for simplicity and for the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
little bit different in a real environment, but for simplicity and for the
purposes of the
examination, we are absolutely fine to do so. So let's just say sudo vice sudo.
And if we scroll
all the way down just below this part here that says route all equals all, all
I'm going to do
here is say Ansible, which is the name of the user accounts, and then say all
equals a name
within parentheses all. And then I would just say no pass wd colon and then the
word all. So if I
just write and quit, let's do the same thing on blue box and yellow box. So
once again, sudo vice WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
once again, sudo vice
sudo and just type in the exact same information again. Perfect. So colon
writing quits. And lastly,
on the yellow box machine, we just sudo vice sudo and again, just type in the
exact same content.
Once again, saving with a wq. So if on my main machine, I just type ipadder, we
can see the ip address
happens to be 192168160.133. And we want to be able to reach the blue box and
yellow box. So
let's see what their IP addresses are. So once again, we just do ipadder on the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
let's see what their IP addresses are. So once again, we just do ipadder on the
blue box, we can
see this is 192168160.134. And over on the yellow box, we are on 160.135. What
I actually want to do
now is to create some SSH keys for login. Now what I'm going to do is I'm going
to create these keys
as the answerable user sources, sudo su hyphen answerable and I enter, we can
now see the username
has changed to answerable right here. And what I'm going to do is say SSH hyp
hen key gen and
enter. That's going to tell me the file where it's going to save automatically. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
enter. That's going to tell me the file where it's going to save automatically.
That is fine. So
I'll just hit enter. It's going to ask me for a passphrase. Now in the real
world, once again,
we absolutely want to be adding a passphrase but for simplicity for the
examination.
Absolutely find you to leave this blank. So let's just hit enter and enter
again. And now we have
automatically generated our SSH key pair, the public key as well as the private
key. Now what
we want to be able to do is to share the public key with the blue box and the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we want to be able to do is to share the public key with the blue box and the
yellow box. This
is going to allow us to authenticate in as the answerable user to those devices
without having to
type in the password answerable, which is going to be much, much better for us
when working an
in automated fashion. So all I will say is SSH hyphen copy ID. And then I will
say answerable at
192.168.168.134, which is the first machine the blue box machine. If I enter, I
will say yes.
And I will type in the password of answerable the very first time I'm doing
this authentication. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
this authentication.
Perfect. We have now added the key to that particular machine for the blue box.
And similarly, if I arrow up and do 135, I answer, I now say yes to add the
fingerprint. I type in
answerable again. I now log into the yellow box and transfer my public key over
to that particular
device. So now moving forward whilst I'm on the red box itself, the answerable
control node,
if I now just want to authenticate into that particular device, say for example
, the blue box,
I can just say SSH, answerable, and then type in the IP address of 192.168.134. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I can just say SSH, answerable, and then type in the IP address of 192.168.134.
And to enter,
notice we authenticate straight away without having to type in the passphrase.
I'm now on the
blue box. See that right there? And again, if I exit out, arrow up, type 135, I
enter,
automatically, we just slide directly into the yellow box without having to
type the password.
That is exactly what we want. So now we have the basic setup of our lab
environments. We have
our three virtual machines. We have now created a dedicated answerable user for
all three devices WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
all three devices
and have now configured passwordless SSH key authentication. With that now done
,
we are ready to begin talking about answerable.