1

I have created keys and put my public key into my github account. Then, in ~/.ssh I created the following config file:

Host github
  HostName [email protected]
  IdentityFile ~/.ssh/id_rsa2.pub

When I do ssh github

ssh: Could not resolve hostname [email protected]: nodename nor servname provided, or not known

And when I do ssh -T [email protected]

Permission denied (publickey).

What am I doing wrong? The public key I put in my github account says "Never used".

Thank you in advance

1 Answer 1

4

The problem is, you are trying to use the public key for authentication. The private key, is e.g. id_rsa2 while the public key is id_rsa2.pub, at least per default, when generated with ssh-keygen.

As default ssh uses id_rsa for identification, so you have to use:

ssh -i ~/.ssh/id_rsa2 -T [email protected]

The ssh config should look like this:

Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa2

The Host value is important, because that's what you have to use to use the configuration. You now can use ssh github.com. If you don't change the Host line, you need to use ssh github, but this could break other tools.

Alternatively you could use ssh-agent. In this case you do not need to create the config and just add the key to your ssh-agent and ssh to github.

ssh-add ~/.ssh/id_rsa2
ssh -T [email protected]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.