我使用PuTTy keygen创建了一个公钥 . 我将公钥复制到 david.pub
并发送给将密钥放在服务器(vps)上的开发人员,因此我可以克隆存储库 . 当我创建公钥时,我输入了密码 . 当我尝试克隆时会发生这种情况:
$ git clone my_app:money_app.git new_money_app Cloning into 'new_money_app'... Enter passphrase for key '/c/Users/User1/.ssh/david.pub':
我输入我设置的密码,这行重复3次 Enter passphrase for key '/c/Users/User1/.ssh/david.pub':
然后显示
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
存储库存在 . 这是我的配置文件的外观:
Host my_app
User git
HostName xx.xx.xxx.xx
PubkeyAuthentication yes
PreferredAuthentications publickey
IdentityFile ~/.ssh/david.pub
我如何解决这个问题,以便克隆存储库?我是GIT的新手,我需要重新创建公钥吗?我被告知要创建一个公钥,我还需要一个私钥吗?
我是前端开发人员,所以这很令人困惑 .
1 回答
这不是Git问题,只是ssh . 您可以通过尝试ssh进入计算机来更轻松地调试问题 .
ssh my_app
应该给你同样的问题 .公钥不应该有密码,应该提示你有什么问题 . 它's asking you over and over again because you'重新输入密钥没有的密码 . 您的私钥有密码 .
在ssh中有两个键,一个是公共的(
~/.ssh/david.pub
),另一个是私有的(~/.ssh/david
) . 如果没有私钥,您就无法创建公钥 . 私钥是你的秘密,它与你同在,它应该受密码保护,以防它被盗 . 公钥用于您要登录的服务器 . 私钥用于解锁用公共密钥加密的内容(反之亦然) .问题是这一行:
这应该是您的私钥,
~/.ssh/david
.