Using ssh keys to authenticate to a server can be a convenient and secure alternative to using a username and password on a Linux server. This tutorial will show you the steps using passwordless authentication with ssh keys.
Use the program “ssh-keygen” to generate your public and private key pair.
ssh-keygen
You should see the public and private keys you just created.
ls -la ~/.ssh/
You can think of this key pair as a lock and key to your front door.
The Public key is the actual lock on your door. Everyone can see it, and that’s ok.
The actual key to open your front door is your private key. This must be protected from the public.
You can, and should, share your public key to use with services like github.com.
Start sharing your keys, by sharing them with yourself.
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 400 ~/.ssh/authorized_keys
ssh <your_hostname>
Or
ssh localhost
Get an error trying the to ssh to localhost?
The authorized_keys files must be set to read only by the user, or else the ssh daemon will throw an error that this file is too open.
The authorized_keys file is the file that holds all public keys that can be used to access this account, on this computer.
You can add your ssh key to authorized_keys files on another computer to be able to login there, using keys, and not using a password.
ssh-copy-id <remote_host>
or just copy and paste the public key (id_rsa.pub), if possible.
or set up a quick python web server and curl it down from the other machine
Then ssh to the remote machine
Great Success!!!