3

I'm following the instructions on this video of how add second github account. But I'm getting this error:

ssh: Could not resolve hostname github-secondAccount: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Here is what I have done.

I add it a second sshkey:

id_rsa
id_rsa.pub
id_rsa_secondAccount
id_rsa_secondAccount.pub

And also created a config:

#first account
        Host github.com
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_rsa

#secondAccount account
        Host github-secondAccount
        HostName github.com
        User git
        IdentityFile id_rsa_secondAccount


echo "# myNewRepo" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github-secondAccount:myUSer/myNewRepo.git
git push -u origin master

But at the moment of git push -u origin master I'm getting this error:

ssh: Could not resolve hostname github-secondAccount: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Any of you knows what I doing wrong or how can fix this?

I'll really appreciate your help.

user2924482
  • 8,380
  • 23
  • 89
  • 173

1 Answers1

4

The URL should be github-secondAccount:myUser/myNewRepo.git (no need for git@)

Make sure your ~/.ssh/config file is protected as 600.
And the second IdentityFile should be ~/.ssh/id_rsa_secondAccount.

Finally, make sure id_rsa_secondAccount.pub (public key) has been published to myUser SSH keys setting page.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • you mean the permission should be `600`? – user2924482 Jun 28 '18 at 05:53
  • What you mean `(public key) has been published to myUser SSH keys setting page`? – user2924482 Jun 28 '18 at 05:55
  • @user2924482 I mean: https://help.github.com/enterprise/2.13/user/articles/adding-a-new-ssh-key-to-your-github-account/ – VonC Jun 28 '18 at 06:06
  • @user2924482 yes, 600 for the files within ~/.ssh, 700 for ~/.ssh itself: https://stackoverflow.com/a/37626619/6309 – VonC Jun 28 '18 at 06:07
  • I have publish the key and set the permissions but still have the same error. – user2924482 Jun 28 '18 at 19:20
  • @user2924482 check if your ~/.ssh/config file has LF end of line characters, not crlf (https://stackoverflow.com/q/18084456/6309). Then copy in a gist (https://gist.github.com/) the output of `ssh -Tv github-secondAccount` (just `github-secondAccount`, not `github-secondAccount:xxx`: remove the confidential parts (like actual servername or ip address) You should see a Welcome message: https://help.github.com/articles/testing-your-ssh-connection/ – VonC Jun 28 '18 at 20:26
  • @user2924482 did you find what was missing in order to make it work? – VonC Jun 29 '18 at 05:02