Bitbucket ssh公钥被拒绝,但他们的ssh测试连接没有问题

Iva*_*nna 9 git ssh bitbucket ssh-keys

一个非常可能相关的信息是我为bitbucket设置了自定义ssh配置.在我的'.ssh/config'文件中,我有以下内容:

[ivanna@comp]$ cat ~/.ssh/config 
Host bitbucket
    Hostname        bitbucket.org
    IdentityFile    /home/ivanna/.ssh/id_rsa_bitbucket
    IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)

就ssh而言,此文件的权限肯定是正确的(我主动使用配置文件中的其他条目).现在,当我在git中添加远程源时,我使用了bitbucket而不是bitbucket.org:

git remote add origin bitbucket:ivanna/my-repo.git
Run Code Online (Sandbox Code Playgroud)

但是当我尝试推送时,我收到以下错误:

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)

所以好像我没有添加我的公钥或其他什么,对吧?但我绝对做到了.当您搜索更多信息时,您会找到有关错误的页面(https://confluence.atlassian.com/pages/viewpage.action?pageId=302811860).当我按照他们的意思去检查密钥时:

[ivanna@comp]$ ssh -T hg@bitbucket
logged in as ivanna.

You can use git or hg to connect to Bitbucket. Shell access is disabled.
Run Code Online (Sandbox Code Playgroud)

它看起来可以正常登录.那么......为什么不推动工作呢?上面的链接提到它可能是项目本身的权限问题,但我按照人们的建议设置了权限,但没有做任何事情.谁知道发生了什么事?

pok*_*oke 7

ssh -T hg@bitbucket
Run Code Online (Sandbox Code Playgroud)

hg@bitbucket通过SSH登录时使用,但在添加到Git的远程URL中,您没有指定用户名.由于配置也不包含一个,Git将不知道登录的用户名.

将URL更改为:

git remote add origin git@bitbucket:ivanna/my-repo.git
Run Code Online (Sandbox Code Playgroud)

或者,您可以将用户添加到SSH配置:

Host bitbucket
    Hostname        bitbucket.org
    User            git
    IdentityFile    /home/ivanna/.ssh/id_rsa_bitbucket
    IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,那就尴尬了。 (2认同)