- All right.
In this video, we are going to explore key based SSH login.
Now, what is the thing?
The thing is set by default.
SSH access is based on username and password.
And username and password,
that's something that can be guessed or stolen.
If you want to enhance security
consider using key based access.
Key based access is based on something that a user has
and it's difficult to guess a key.
It must be stolen
and because it's more complicated, it increases security,
if you use key based access.
Now in key based access,
the user creates a key pair and next is key pair is copied
over to the SSH host and for additional protection,
the key may be protected with a passphrase as well.
Now, in order to create a key pair
SSH key gen is the first thing to do.
SSH copy ID to the SSH service,
second thing to do.
Now, let's talk about these pass phrases a little bit.
To add protection to SSH keys,
it should be protected with a passphrase.
What is that?
Well, that means that you have basically what
we call multifactor authentication.
So the authentication with SSH pass phrase
protected keys is based
on something the user has and something the user knows.
So just stealing your key would not be enough to
hack your account
But there's one downside.
Every time you initialize a session
you need to enter the passphrase, and that is annoying.
And that's why we have SSH agent.
To fix this problem,
you can use SSH agent /bin/bash.
That will run the SSH agent
which can catch the pass rates for the session duration.
Next we use SSH add to add the current key
to the agent and you'll enter the pass rates once.
And from that moment on for the entire duration
of the session, you won't have to enter it again.
Of course, if you exit your session
and you start a new session, you will
you will need to repeat this procedure, but using SSH agent
and SSH add is the ideal balance
to convenience and security.
All right, from the Ubuntu machine, I'm going to start
with SSH key gen to generate the key pair.
This is asking where to store the key.
Well, this is the, the private key.
I wanna store it in id_rsa.
That's okay.
Here it's asking for the passphrase.
If you do not want to work
with the passphrase, you just press enter
but I do want to work with the passphrase.
So I'm going to enter it here.
And again, now it has created the private key,
it has created the public key.
There's even a public key fingerprint and
and a key random art image
which can be used for verification.
But I'm going to copy over this key
to the remote host because that is what is required
in order to work with SSH keys.
So SSH copy ID.
Hey, can we use --help to figure out the port usage?
Yes, we can.
- P for port 2022.
So -p 2022
192.168.29.101.
So it's asking for the password for the current user.
There we go.
And it has just copied it over.
So now we can check and how do we do that?
Well, SSH -p 2022 to 192.168.29.101.
And now it's asking for the passphrase.
So here we go, passphrase and I have access
but the annoying thing is the next time it's asking
for the passphrase.
So every time you need to enter a passphrase
that does make it very secure.
That's true, but it's not very convenient.
So first we use SSH agents /bin /bash
to start the SSH agent for the bash l.
Then we use SSH add to actually add the S passphrase
to the agent.
And there we go.
You can see that the identity is added
and now we can use SSH -p 2022
to this host again
and it's not asking for anything anymore.
And that is how you can use SSH keys together
with SSH agent and SSH add to make S access
to your SSH server,
secure and convenient.