If you have access to the gerrit server, you can use StephenKing's answer, and add a ~/.ssh/config
file which will specify where are the key to use:
Host github.com
User git
IdentityFile /path/to/the/private/key
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
But if you used default id_rsa
and id_rsa.pub
(which should have been picked up by ssh), then check on that same Gerrit server the value of $HOME
, as I mention in a previous answer.
As StephenKing mentions in the comments:
The part of the error message to helps identifying the problem is rejected HostKey:
github.com
.
If ssh
doesn't find valid id_rsa(.pub)
in $HOME/.ssh
, then it looks for a ~/.ssh/config
file with a "github.com
" entry in it which would tell ssh where to find the right ssh key to connect to the server represented by "github.com
".
The issue was:
Since I started gerrit with sudo, it was running as root. now I changes and it works fine
So if the keys were registered in a user HOME
, they weren't visible by a process launched by root.