ssh public key authentication

On the web there isn’t a neatly written public key ssh authentication tutorial
Here I write mine:

This is related to the OpenSSH. There is another method related to OpenSSL.
1. Generate your key if they don’t exist in the client, after the command below, you may find it in ~/.ssh/
ssh-keygen -t rsa

2. in ~/.ssh/, “id_rsa.pub" is the public key, “id_rsa" is the private key. Always keep this folder secured.

3. Copy the file to the server, the home folder of the user to-be-login
scp id_rsa.pub userA@server.com:/home/userA/.ssh/id_rsa.pub

4. Login the server. Add the key to the list of authorized key
cat ~/.ssh/uploaded_key.pub` >> ~/.ssh/authorized_keys

5. Done. Login with this command:
ssh userA@server.com or
ssh -i ~/.ssh/id_rsa userA@server.com

發表留言