git使用authorized_keys作为身份验证

时间:2016-02-28 16:08:51

标签: git authentication server

我跟着the official tutorial以便第一次设置git服务器。当我执行以下操作时:

$ git remote add origin git@gitserver:/opt/git/project.git
$ git push origin master

我被问到git@gitserver的密码,我认为这个密码很奇怪,但无论如何都输了。

然后当我尝试通过这样做克隆存储库时:

$ git clone git@gitserver:/opt/git/project.git

或使用它推送到它:

$ git push origin master

我每次都被要求输入git@gitserver的密码。我检查了authorized_users包含试图推送或克隆的用户的公钥。此外,我尝试了this question的建议答案,但这没有帮助。

如何设置服务器和客户端,以便每次提交时都不会要求我输入密码?

更新

ssh -v -i ~/.ssh/id_rsa git@gitserver的输出:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to gitserver [XXX_REDACTED_gitserver_IP] port 22.
debug1: Connection established.
debug1: identity file /home/XXX/.ssh/id_rsa type 1
debug1: identity file /home/XXX/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA XXX_REDACTED_PUBLIC_KEY_XXX
debug1: Host 'gitserver' is known and matches the ECDSA host key.
debug1: Found key in /home/XXX/.ssh/known_hosts:12
debug1: ssh_ecdsa_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,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/XXX/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
debug1: Authentications that can continue: publickey,password
git@gitserver's password:

1 个答案:

答案 0 :(得分:1)

请确保您使用正确的私钥/公钥对。 您可以使用SELECT value_a, COUNT(*) value_a_count FROM table_a GROUP BY value_a 直接指向密钥并检查输出来验证这一点。