我想推送到一个远程 git 仓库,但我三次输入了错误的密钥密码。我已经创建了一个新的 SSH 密钥,并将新的公钥注册到仓库服务器上。 但是 SSH 代理不会提示输入密码,只会持续告诉我:
Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
我该如何在 Ubuntu 下解决这个问题?
编辑
根据建议,我尝试了 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没有提示输入密码。即使重新启动或注销也是如此。
编辑
正如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
复制到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
?
~/.ssh
目录下?你是否执行了chmod 700 ~/.ssh
命令? - Jonathan.Brink