如何在 Bitbucket 项目中使用 SSH 密钥?

ric*_*mos 4 git ssh bitbucket

我在 Bitbucket 中生成和使用 SSH 密钥的步骤:

  1. ssh-keygen -t rsa -C "my email"
  2. cat ~/.ssh/id_rsa.pub
  3. 将我的密钥复制ssh-rsa AAAAB3Nz... my email到剪贴板
  4. 在 bitbucket 中访问我的配置 > SSH 密钥
  5. 添加密钥
  6. 在我的 ubuntu 控制台中,我使用以下命令:ssh -T git@bitbucket.org

使用步骤 6 中的命令后,将出现以下消息:

$ ssh -T git@bitbucket.org
logged in as ricardoramos.

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

当我推送到我的存储库时,仍然需要我的密码。

每次推送都必须输入密码,这非常烦人。

我哪里错了?

jor*_*ane 5

您无法使用 SSH 登录 bitbucket 的 shell,但您确实正确设置了密钥,否则您不会收到“Shell 访问已禁用”消息。

您所要做的就是更改存储库的 URL。现在您已经设置了 HTTPS URL,它需要密码。您可以切换到 SSH URL,如下所示:

git remote set-url origin [ssh url of your git repo]
Run Code Online (Sandbox Code Playgroud)