开发者

Why can't I "git clone" from my server with a key that works from my local machine?

开发者 https://www.devze.com 2023-04-09 10:19 出处:网络
This is the content of /home/ubuntu/.ssh drwx------ 2 ubuntu ubuntu 4096 2011-09-28 02:32 . drwxr-xr-x 5 ub开发者_如何学Cuntu ubuntu 4096 2011-09-28 02:08 ..

This is the content of /home/ubuntu/.ssh

drwx------ 2 ubuntu ubuntu 4096 2011-09-28 02:32 .
drwxr-xr-x 5 ub开发者_如何学Cuntu ubuntu 4096 2011-09-28 02:08 ..
-rw------- 1 ubuntu ubuntu  396 2011-09-27 20:53 authorized_keys
-rw------- 1 ubuntu ubuntu  115 2011-09-27 21:10 config
-rw------- 1 ubuntu ubuntu 1670 2011-09-27 21:10 id_rsa
-rw------- 1 ubuntu ubuntu  397 2011-09-27 21:10 id_rsa.pub
-rw-r--r-- 1 ubuntu ubuntu  407 2011-09-28 02:07 known_hosts

id_rsa.pub is already a key added to my github account because if I try to add it, it tells me it already exists. It's also the key that allows me to git clone from my local machine. But when I try to git clone something from the server:

$ git clone git@github.com:redCashion/ruby-mysql.git
Cloning into ruby-mysql...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly 


For diagnostic, try ssh -T git@github.com, it should give something like:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

If that fails, you do not have your keys setup right or it is using some other keys. Try:

ssh -vT git@github.com

to see what private key it is trying. Make sure it is at /home/ubuntu/.ssh like you expect it to be.


You can try ssh'ing directly to github, and it will give you some diagnostic info. On top of that, use ssh -vvv ... to get very verbose output about what's happening. You may find that it's not using the key you think it is. If that's the case, check the contents of ~/.ssh/config.

0

精彩评论

暂无评论...
验证码 换一张
取 消