I find myself always having to search for the steps to do key authentication for ssh. This post is to be a personal quick reminder of the required steps. See link here for a more detailed walk through.
Generate private/public key pair on the local computer.
ssh-keygen -t rsa -b 4096
The 4096 is just for a longer key for security reasons. By default, this stores the keys at
~/.sshin the files
Transfer the public key to the remote computer that you are attempting to ssh into.
You’ll need to enter in the user’s password at this step. If all goes according to plan, at this point, you should be able to do
ssh user@hostand not enter in a password.
Give the hostname/IP address an alias so that it is easier to remember.
You can alias the IP address for ssh using the
~/.ssh/configfile. For example, to ssh into the server that hosts my psychrometric chart page, I have the following lines (not the actual IP address).
Host psy User root Hostname 192.168.0.0
With those lines added to the
~/.ssh/config file, I can now use the command
and I’m in.