My ~/.ssh
contains two keypairs:
id_rsa_foo
&id_rsa_foo.pub
- for user
foousername
on GitHub (github.com
)
- for user
id_rsa_bar
&id_rsa_bar.pub
- for user
barusername
on GitHub (github.com
) - for user
barusername
on my server (indefero.myserver.com
)
- for user
The ~/.ssh/config
"knows" the keyfiles:
#github.com-foousername account
Host github.com-foousername
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_foo
#github.com-barusername account
Host github.com-barusername
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_bar
#indefero.myserver.com-foousername account
Host indefero.myserver.com-foousername
HostName indefero.myserver.com
User foousername
IdentityFile ~/.ssh/id_rsa_bar
The ~/.ssh/known_hosts
"knows" the server:
github.com,207.97.227.239 ssh-rsa AAAAB3N...AaQ==
204.232.175.90 ssh-rsa AAAAB3N...AaQ==
indefero.myserver.com,111.222.333.444 ssh-rsa AAAAB3N...Ytw==
Now when I'm trying to clone from GitHub, an error ocurres: Permission denied (publickey). fatal: The remote end hung up unexpectedly
user@machine ~/Desktop/test
$ git clone git@github.com:foousername/project1.git
Cloning into 'foousername'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
But when I create a repository on my local machine first and set the local/project config
up:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com-foousername:foousername/project1.git
I can pull
/push
. (This way works for the GitHub repos, the myserver ropos don't want even so and require a password: indefero@indefero.it-and-t.com's password:
. But might be another problem.)
How can I change this behaviour, in order to clone repos?