Public key authentication with SSH
Public key authentication is a secure way to log in to a virtual private server or a cloud instance through SSH. It provides better security and cryptographic strength than any strong password in use. When setting up SSH key authentication, we generate a pair of two keys, a private and a public key. From those two keys, the private key will be stored on the local machine, and the public key will be used on the host VM. The keys are stored inside the .ssh
directory in your user’s home directory. To generate a new pair of keys, you will have to use the ssh-keygen
command.
It can be used with options, the most relevant ones being: -t
to specify the type of encryption algorithm used, -b
to specify the number of bits. Used with no option, the ssh-keygen
command will use the RSA encryption algorithm and a 3,072-bit key. The following is the output for using the command as is:
Figure 11.23 – Using the ssh-keygen...