【问题标题】:Setting up git on Linux server在 Linux 服务器上设置 git
【发布时间】:2012-05-20 04:20:35
【问题描述】:

我正在尝试在运行 Linux RedHat 的服务器上设置 git 存储库。

我按照 Github 帮助页面上的说明进行操作。我到达了指令告诉我 ssh 进入 git@github.com 的步骤。

这给了我以下错误 -

 $ ssh -T git@github.com
 Permission denied (publickey).

然后我做了 $ ssh -vT git@github.com 并得到了这个 -

 OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
 debug1: Reading configuration data /home/min/a/foo/.ssh/config
 debug1: Applying options for *
 debug1: Reading configuration data /etc/ssh/ssh_config
 debug1: Applying options for *
 debug1: Connecting to github.com [some IP] port 22.
 debug1: Connection established.
 debug1: identity file /home/shay/a/foo/.ssh/id_rsa type -1
 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github2
 debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github2 pat OpenSSH*
 debug1: Enabling compatibility mode for protocol 2.0
 debug1: Local version string SSH-2.0-OpenSSH_5.3
 debug1: SSH2_MSG_KEXINIT sent
 debug1: SSH2_MSG_KEXINIT received
 debug1: kex: server->client aes128-ctr hmac-md5 none
 debug1: kex: client->server aes128-ctr hmac-md5 none
 debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
 debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
 debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
 debug1: Host 'github.com' is known and matches the RSA host key.
 debug1: Found key in /home/min/a/foo/.ssh/known_hosts:1
 debug1: ssh_rsa_verify: signature correct
 debug1: SSH2_MSG_NEWKEYS sent
 debug1: expecting SSH2_MSG_NEWKEYS
 debug1: SSH2_MSG_NEWKEYS received
 debug1: SSH2_MSG_SERVICE_REQUEST sent
 debug1: SSH2_MSG_SERVICE_ACCEPT received
 debug1: Authentications that can continue: publickey
 debug1: Next authentication method: publickey
 debug1: Trying private key: /home/shay/a/foo/.ssh/id_rsa
 debug1: No more authentication methods to try.
 Permission denied (publickey).

这是我目前所在的位置 -

 $ pwd
 /home/min/a/foo/.ssh

我不明白出了什么问题?另外,如果我尝试通过 ssh-add 添加此路径,它会显示“无法打开与您的身份验证代理的连接”。

【问题讨论】:

  • 您是否生成/上传了您的 ssh-gen 密钥>?
  • 是的。我按照 github 帮助页面上的说明进行操作,我可以在我的密钥中看到第二个密钥(我的笔记本电脑已经有一个密钥并且它可以工作)。

标签: linux authentication github redhat ssh-keys


【解决方案1】:

您似乎没有将密钥上传到 github,或者您上传的密钥与当前用户的默认密钥不匹配。

检查您的本地密钥是否在 github 上:

或者,检查您的密钥是否在 github 上启用。不久前,有一个security issue related to ssh keys on github。所有 ssh 密钥都被禁用,以强制用户查看他们允许的密钥列表。如果您最近没有使用 github,您的仍然可能被禁用。

【讨论】:

  • 别忘了检查 .ssh 的 权限 - 如果权限太高,密钥身份验证将不起作用。
  • @ThomasM.DuBuisson:这是真的,但调试输出(Permissions 0777 for '/home/david/.ssh/id_dsa' are too open.could not open key file '/home/david/.ssh/id_dsa': Permission denied)中会显示不正确的权限(太宽或太窄)。这至少是 openssh 5.9 的行为(OP 使用的是 5.3)。
  • 我没有意识到它实际上会告诉你。很高兴知道!
  • 不幸的是,情况并非如此。我使用 vezult 给出的说明检查了两个密钥是否相同(谢谢您的时间,顺便说一句),我确保权限已更改为只能由我读取和写入(我在实验室组中,我的导师要求完全访问实验室内的所有内容 - 我将 ssh 的此项更改为只有我自己)。这些都没有奏效。相同的结果 - 权限被拒绝。我最近添加了这个密钥(在我发布原始问题前几分钟),所以我不认为这是我的问题。
【解决方案2】:

以防万一有人感兴趣或有类似问题并查看此帖子,解决方案是从 .ssh 目录 cd 并 ssh 进入 github。如果其他所有内容都完全按照 github 的帮助页面进行,这将解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-08
    相关资源
    最近更新 更多