当使用SSH连接时,git clone会失败

我用下面的命令来克隆一个git仓库

git clone ssh://git@test.server.com/project.git 

我把密钥文件id_rsa.pubid_rsa放在~/.ssh/文件夹中,但是当试图用上面的git命令克隆时,我得到以下错误。

 ssh -v git@test.server.com OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010 debug1: Reading configuration data /home/user/.ssh/config debug1: Applying options for test.server.com debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to test.server.com [xxxx] port 22. debug1: Connection established. debug1: identity file /home/user/.ssh/id_rsa.pub type 1 debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048 debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048 debug1: identity file /home/user/.ssh/id_rsa.pub-cert type -1 ssh_exchange_identification: Connection closed by remote host 

您必须在/home/git/.ssh/authorized_keys服务器上添加您的本地密钥(位于/home/user/.ssh/id_rsa.pub

您可以使用ssh-copy-id将您的公钥发送到服务器。