Linux: using auth keys to connect via ssh

Published by

Posted on November 19, 2014

Generate key on local machine

ssh-keygen -t rsa

It will ask you for a password but you can leave it blank.

Note you could also pick -t dsa if you prefer.

Ensure that the remote server has a .ssh directory

Make sure the server your connecting to has a .ssh directory in your home
directory. If it doesn’t exist you can run the ssh-keygen command above, and
it will create one with the correct permissions.

Copy your local public key to the remote server and auto update the auth file on the remote server.
ssh-copy-id user@

if you prefer to do it the old way then use the instructions below.
>>>>If your remote server do not have a file called ~/.ssh/authorized_keys
then create it.
scp ~/.ssh/

If that file already exists, you need to append to it.
instead of overwriting it.
You can test the settings by ssh using the -i flag
ssh -i privatefilename user@remotehost

Now you can ssh to the remote server without entering your password.


Possible errors:

Authentications that can continue
check the server logs for 
Authentication refused: bad ownership or modes for directory

chmod the home directory 
chmod 755 /home/xxx