To make SSH login a little bit more convenient, it's common to use keys.
So SSH keygen is what you can use to create a public-private key pair for the current
user.
And these keys can be used for authentication.
The private key is the identity of the user.
The public key is copied over to the remote server where the user wants to log into.
As the private key is the user identity, it might be a good idea to set a passphrase
on this private key.
That will make it more secure, but less convenient.
The security is that before the user can use the private key, the passphrase needs to be
entered.
But the downside is that the user needs to enter the passphrase all the time.
I'll later tell you about SSH agent that can be used as a solution for that.
Now to get the public key up to the server where you want to log into, SSH copy ID is
used.
Let me show you.
All right.
Let me do this as an ordinary user, because the root user by default cannot log into SSH.
And that is good, because it makes the server less vulnerable.
Now let me use SSH keygen, which will generate the public-private key pair.
Our first question is, where do we want to save the key?
The key?
That is a private key.
That's a user identity.
And this is where you can enter the passphrase if you want to.
For now, I'm going to hit Enter to set no passphrase.
And then hit Enter again to verify that we really don't want a passphrase.
And now it's done.
And in order to use it, I need to SSH copy ID.
And I'm copying it over to an external server, the 192.168.29.143.
Now this happens to be the first time I'm logging into this server.
And that is why it's printing the message about the identity, where I'm entering yes.
And then it's asking for my current user password.
And now it's telling me that one key has been added.
And that means that at this point, I should be able to use SSH to 192.168.29.143.
And then I'm on the remote server without having to enter a password whatsoever.
That's very convenient.
It's also very insecure.