Issue: git@github: Permission denied (publickey)
Issue: git@github: Permission denied (publickey)
Solution:
First check if your public key exists in your GitHub account: keysIf not you must add it. In order to add it you must find it.
cat ~/.ssh/id_rsa.pub
Check that you can connect to git:
ssh -vT git@github.com
jenkins@d247c7beca6a:~$ cat /var/jenkins_home/.ssh/id_rsa.pub
ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx== manast@in.xxx.com
jenkins@d247c7beca6a:~$ ssh -T git@github.xxx.com
Hi manast! You've successfully authenticated, but GitHub does not provide shell access.
jenkins@d247c7beca6a:~$
jenkins@d247c7beca6a:~$ cat /var/jenkins_home/.ssh/id_rsa.pub
ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx== manast@in.xxx.com
jenkins@d247c7beca6a:~$ ssh -T git@github.xxx.com
Hi manast! You've successfully authenticated, but GitHub does not provide shell access.
jenkins@d247c7beca6a:~$
Another reason why you fail, may be a missing .config file in your ~/.ssh folder.
If this is the case, just create it and paste the following into it:
Host github.com
User git
Port 22
Hostname github.xxx.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
User git
Port 22
Hostname github.xxx.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
Other reason could be : ssh will refuse to use any key file that is not readable only by the owner. make sure that the private and public keys are readable only by you (chmod 600 ~/.ssh/id_rsa.*)
No comments