Atlassian Bitbucket Cloud - ssh 身份验证 - git pull 有效,git push 失败

use*_*542 6 git bitbucket bitbucket-cloud

1. 总结问题

我按照 Bitbucket 的说明设置 ssh。

我有一个 pub/priv 密钥对,并将 pub 密钥粘贴到项目的 Bitbucket 设置(访问密钥)中。

我在 GCE VM 上有一个构建服务器。 git clone工作成功,并且git pull origin master有效。我正在使用密码。

git commit但是,如果我在 GCE VM 上对单个文件进行小更改,然后执行git push origin master,则会失败并显示以下错误消息。

Enter passphrase for key '/home/proc/.ssh/id_rsa':
Unauthorized
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 remote -v 节目

origin  git@bitbucket.org:<my-account>/<my-repo>.git (fetch)
origin  git@bitbucket.org:<my-account>/<my-repo>.git (push)
Run Code Online (Sandbox Code Playgroud)

如果git pull origin master工作正常,则 ssh 设置正确。

我添加了以下文件:$HOME/.ssh/.config,其内容如下,但没有帮助。

Host bitbucket.org
 IdentityFile ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)

我的密钥文件是通过以下内容生成的: ssh-keygen -t rsa -b 4096 -C "<comment>"

2. 提供背景信息,包括您已经尝试过的内容

我读过所有关于 Bitbucket 身份验证问题的堆栈溢出文章。

3.展示一些代码

git add <changed file>

git commit -m "made some updates"

git push origin master

4. 描述预期的实际结果,包括任何错误消息

我正在尝试git push origin master访问 bitbucket.org。

小智 1

ssh-agent /bin/sh然后ssh-add ~/.ssh/id_rsa使用您的私钥名称运行(替换 id_rsa)。你的推动应该有效。