01.08SSH Login Using Public Key Authentication
Step 1: Generate Keypair on Localmachine
ssh-keygen -t dsa
When prompted for a passphrase you can leave it empty to enable logging in without a password (please note that there are potential security issues with doing this).
After confirming your passphrase at the second prompt you’ll find two new files (the keypair) in your ~/.ssh directory. The first file id_dsa is your private key, the second file id_dsa.pub your public key.
Step 2: Set Local ~/.ssh Permissions
chmod 700 ~/.ssh
Step 3: Copy Public Key to Remote Server
scp ~/.ssh/id_dsa.pub username@remoteserver:~/id_dsa.pub
Step 4: Login to Remote Server:
ssh username@remoteserver
Step 5: Update Authorized Keys on Remote Server
cat id_dsa.pub >> ~/.ssh/authorized_keys
Step 6: Set Remote ~/.ssh Permissions
chmod 600 ~/.ssh/authorized_keys
Done!
At this point you should be able to login to the remote server without using a password.
ssh username@remoteserver - or - ssh -i ~/.ssh/id_dsa username@remoteserver

Leave a Reply