I have a ssh key without a password to login to a remote system. Let's assume the remote server is called server-name and has the same user as the one I'm currently logged in. In the console if I do the following:

ssh server-name

A popup appears which asks me to enter my password. If I do not enter any password I get the error message Permission denied (publickey).

However, doing this:

ssh -i ~/.ssh/my_key_rsa server-name

works fine.

I also found on the net, that adding AskPassGUI no to ~/.ssh/config prevents the popup from being shown. However, then I get the following:

Tom@computer:~/.ssh$ ssh server-name
Enter passphrase for key '/Users/Tom/.ssh/my_key_rsa.pub': 
Permission denied (publickey).

So, what do I have to do in order to login without the -i option?

Note: I set the correct key files in ~/.ssh/config for accessing the corresponding remote machine, i.e.

Tom@computer:~/.ssh$ cat ~/.ssh/config 
AskPassGUI no
Host *
    IdentityFile ~/.ssh/my_key_rsa.pub
  • 1
    You need to specify your private key as IdentityFile, not the public one.
    – Sven
    Apr 25, 2015 at 15:12

1 Answer 1

Host *
    IdentityFile ~/.ssh/my_key_rsa.pub

You've specified the wrong key file here. You need to specify the private key file, not the public key file. The private key file is the one without the .pub extension:

Host *
    IdentityFile ~/.ssh/my_key_rsa

You must log in to answer this question.