我想推送远程 git 存储库。我输入了错误的密码三次。我创建了一个新的 ssh 密钥并在存储库服务器上注册了新的公钥。
但 ssh 代理不会提示输入密码。它只是不断地告诉我:
权限被拒绝(公钥)。致命:无法从远程读取
存储库。
请确保您拥有正确的访问权限和存储库
存在。
ubuntu下如何解决这个问题?
Edit
正如建议的那样,我尝试了ssh-add
sadik@sadix:~$ cd .ssh/
sadik@sadix:~/.ssh$ ls
config github_rsa github_rsa.pub id_rsa id_rsa.pub keys.zip known_hosts
sadik@sadix:~/.ssh$ ssh-add
Enter passphrase for /home/sadik/.ssh/id_rsa:
Identity added: /home/sadik/.ssh/id_rsa (/home/sadik/.ssh/id_rsa)
sadik@sadix:~/.ssh$
sadik@sadix:~/.ssh$ cd
sadik@sadix:~$ cd some/git-repo/
sadik@sadix:~/some/git-repo/$ git push -u bitbucket master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我应该补充一点,这个 git 存储库是从 github 克隆的(不属于我)。我想将它推送到我的 bitbucket 上的私人存储库上。
我不知道这是否会导致权限问题,但我的第一个问题是 ssh 不提示输入密码。即使重新启动或注销后也是如此。
Edit
正如 Jakuje 善意地建议我输入命令GIT_SSH_COMMAND="ssh -vvv" git push -u bitbucket master
获取客户端日志。这是输出的结尾:
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/sadik/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/sadik/.ssh/id_dsa
debug3: no such identity: /home/sadik/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/sadik/.ssh/id_ecdsa
debug3: no such identity: /home/sadik/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/sadik/.ssh/id_ed25519
debug3: no such identity: /home/sadik/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
无论出于何种原因,它都会搜索公钥id_dsa
,所以我复制了id_rsa
to id_dsa
并再次尝试。
现在它提示输入密码!但是......当我输入错误的密码时,它会再次询问我。当我输入正确的时候,它说权限被拒绝。
$ git push -u bitbucket master
Enter passphrase for key '/home/sadik/.ssh/id_dsa':
Enter passphrase for key '/home/sadik/.ssh/id_dsa':
Enter passphrase for key '/home/sadik/.ssh/id_dsa':
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
- 权限有什么问题吗?
- 为什么要寻找
id_dsa
代替id_rsa
?