Login to SSH with Keys instead of Password
Everyone knows the power of SSH. SSH’s usefulness blows major security issues out of the water, when you authenticate with your server from your local computer using public key authentication.
I mess up a lot with PC, and one day, whatever the reasons were, I couldn’t seamlessly log into my server, and had to enter password. I don’t hate passwords, but just typing them in all the time is boring. I’ve been enduring this nightmare for a while, but went reading what the problem is. Figured the solution is simple:
First: Reset your server pairing information on your local PC:
ssh-keygen -R SERVER_IP_ADDRESS
Then: Generate new ssh id_rsa on your local PC:
local~$ ssh-keygen # will generate this output Generating public/private rsa key pair. Enter file in which to save the key (/Users/localuser/.ssh/id_rsa):
Next: Copy generated key to server which will be used for authentication. I used ssh-copy-id for the first time, and the experience was amazing:
ssh-copy-id demo@SERVER_IP_ADDRESS
Now, ssh into your IP address again, and it shouldn’t ask you for password to your user account.