我想推一个远程的git存储库。我打错了三遍密码。我创建了一个新的ssh密钥,并在存储库服务器上注册了新的公钥。但是ssh代理不提示输入密码。它一直在告诉我:
拒绝许可(公开密钥)致命:无法从远程存储库读取。 请确保您有正确的访问权限和存储库存在。
我如何在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发布于 2017-06-16 03:15:09
事情看上去很复杂,可能值得从头开始:
ssh-add -D删除所有密钥.检查没有使用ssh-add -l的密钥。如果您看到任何输出,那么您正在遭受这只虫子的困扰。注销、登录并验证ssh-add -l没有产生任何输出。ls -al ~/.ssh并检查那里没有密钥。ssh-keygen创建一个新键。当它要求输出文件使用默认值时,按enter,然后键入两次密码。ls -al ~/.ssh并检查id_rsa和id_rsa.pub是否存在。ssh -T git@bitbucket.org测试连接。如果失败,则发布ssh -vvv git@bitbucket.org的输出。为什么它要寻找
id_dsa而不是id_rsa?
SSH尝试几个键,直到找到一个可以工作的键为止。它尝试了id_rsa,密钥被拒绝了,所以它继续尝试id_dsa。
@Leon提到ssh-add的功劳。
发布于 2017-06-09 08:43:10
我忘了密码,猜错了好几次。所以我创造了一个新的。
我读到,因为你有一个有效的钥匙,你创造了一个新的,你想知道为什么它不工作。
您需要将公钥复制到服务器的authorized_keys。
https://stackoverflow.com/questions/44442869
复制相似问题