错误的密码短语3次:git不再要求密码短语了

Sad*_*dik 12 git ssh ssh-agent

我想推送一个远程git存储库.我输了三次错误的密码短语.我创建了一个新的ssh密钥,并在存储库服务器上注册了新的公钥.但是ssh代理不会提示输入密码.它一直在告诉我:

权限被拒绝(publickey).致命:无法从远程存储库读取.

请确保您具有正确的访问权限并且存储库存在.

如何在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.
Run Code Online (Sandbox Code Playgroud)

我应该补充说,这个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.
Run Code Online (Sandbox Code Playgroud)

无论出于何种原因,则搜索PUBKEY id_dsa,所以我复制id_rsaid_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.
Run Code Online (Sandbox Code Playgroud)
  1. 权限有什么问题?
  2. 为什么要寻找id_dsa而不是id_rsa

tom*_*tom 6

事情看起来很复杂,可能值得重新开始:

  1. 删除〜/ .ssh中不需要的所有键(如果有要保留的键,请考虑将它们移动到其他目录).
  2. 如果存在〜/ .ssh/config,请检查它是否没有可疑行.
  3. 如果您使用的是ssh-agent,请使用删除所有密钥ssh-add -D.检查没有使用的密钥ssh-add -l.如果你看到任何输出,你就会遇到这个错误.注销,登录并验证不ssh-add -l产生输出.
  4. 运行ls -al ~/.ssh并检查那里没有密钥.
  5. 使用创建新密钥ssh-keygen.当它要求输出文件使用默认值时按Enter键,然后键入密码短语两次.
  6. 运行ls -al ~/.ssh并检查id_rsaid_rsa.pub是否存在.
  7. 从Bitbucket中删除现有密钥.
  8. 〜/ .ssh/id_rsa.pub的内容添加到Bitbucket.
  9. 使用测试连接ssh -T git@bitbucket.org.如果失败,请发布输出ssh -vvv git@bitbucket.org.
  10. 检查git命令是否有效.

为什么要寻找id_dsa而不是id_rsa

SSH尝试几个键,直到找到一个有效的键.它试过了id_rsa,关键被拒绝了,所以它继续尝试id_dsa.

感谢@Leon用于提的ssh-ADD.