首页 > 解决方案 > 无法使用 git+ssh 克隆

问题描述


我需要通过 git+ssh (git+ssh://git.host.repository.com) 克隆一个存储库。它失败了,因为它使用我的操作系统用户名而不是我的组织用户名。

Cloning into 'project.name'...
francesco@git.host.repository.com's password:

“francesco”是我的操作系统帐户名,显然无法登录。在 ~/.ssh/config 我添加了:

IdentityFile ~/.ssh/id_rsa.pub

但它没有用。我还尝试更新密钥(其中包含我的公司帐户):

touch ~/.ssh/id_rsa.pub

它仍然尝试使用操作系统用户名登录,而不是公钥中包含的用户名。有什么帮助吗?

标签: gitssh

解决方案


您应该编辑类似于下面的 ssh 配置文件。User可以强制用户使用 for ssh

Host git.host.repository.com
  HostName git.host.repository.com
  User git
  IdentityFile ~/.ssh/github/id_rsa

推荐阅读