Setup SSH RSA passwordless access and solve the Permission denied (publickey,gssapi-keyex,gssapi-with-mic) message

The image below gives a summary of what needs to be done.

Do the following on the Client machine:

  •  Make sure you have the .ssh directory under your home directory.

Your directory should look like this. If it does not exist create it.



  • Create your SSH RSA keys.

On your terminal type the following command.  The command will create two files id_rsa  and    in your .ssh directory.

ssh-keygen -t rsa


  • Copy the contents of  the   file on your remote host under $HOME/gmastrokostas/.ssh/authorized_keys
  • Edit your /etc/ssh/sshd_config file located on the remote host under.

The config file you need to edit is the  /etc/ssh/sshd_config     file. You will need to edit the following parameters.

Uncomment the lines:

RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no #-- This will force an RSA login.

Ensure permissions of the .ssh files for the user you want to login are correct.

chmod 700 $HOME/.ssh

chmod 600 $HOME/.ssh/authorized_keys

Now you can reload your ssh config file by typing:

/etc/init.d/sshd reload


systemctl restart sshd.service


  • Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

If you receive this error you will have to point SSH to read your authorized_keys file from a different location. Reason being is that either your Home directory is encrypted or your user’s .ssh and .ssh/authorized_keys file do not have the correct permissions.

Share Button

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.