bitbucket,ssh 密钥不能有 id_rsa 以外的名称

bitbucket, ssh key can't have name other than id_rsa

如果我的密钥名为 id_rsa.pub 并且我将其放入 bitbucket ssh 设置中。它开箱即用。当我像 id_rsa_else.pub 这样的 ssk-keygen 名称时,然后插入到 ssh 密钥设置。它在说

repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

更新 1

下面给出了上面的错误:

Host andatech_bitbucket_my_username
  HostName bitbucket.org
  User andatech_my_username
  IdentityFile ~/.ssh/andatech_my_username_bitbucket

将以下内容添加到您的 ssh 配置文件中。 通常是文件:~/.ssh/config

Host bitbucket.org
  IdentityFile ~/.ssh/id_rsa_else

id_rsa_else 是您的密钥的名称。这告诉 ssh 在与 bitbucket.org.

交谈时使用哪个私钥

您仓库中的遥控器是 "andatech_bitbucket_my_username" 还是 "bitbucket.org"? (您可以 运行 git remote get-url origin 查看名为 "origin" 的遥控器的 URL。)如果 URL 的第一部分不是 "andatech_bitbucket_my_username"],那么 SSH 将不会在您的配置中引用该节,因此它不会使用您想要的密钥。

如果这是问题所在,那么您可以通过以下两种方式之一解决它:更新存储库以使用 "andatech_bitbucket_my_username" 而不是 "git@bitbucket.org" 或您在此处列出的任何内容(git remote set-url origin andatech_bitbucket_my_username ), 或者更新你的 ~/.ssh/config 以用 Host bitbucket.org 代替 Host andatech_bitbucket_my_username.

Host bitbucket.org 
  HostName bitbucket.org
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/andatech_xxx_bitbucket

基于此:https://confluence.atlassian.com/bitbucket/configure-multiple-ssh-identities-for-gitbash-mac-osx-linux-271943168.html