由于客户的隐私要求,我创建了多个帐户来访问不同的git。在一些帮助下,我在dir config中创建了文件~/.ssh和多个ssh键。 使用终端,我已经能够对git 执行所有操作。但是,如果我使用XCode来执行那些操作,它表示为failed to authenticate

xcode - 多个git帐户不适用于Xcode-LMLPHP

这是~/.ssh/config的内容:

Host bitbucket.org
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/id_rsa

Host bitbucket-myAccount2
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/acc2ssh

~/.ssh/内部,我已经有了id_rsaid_rsa.pubacc2sshacc2ssh.pubid_rsa是我通常的git帐户,而acc2ssh是另一个私有(private)帐户。

如果使用终端机,没关系,但是每次都要求输入密码。
$ git remote -v
origin  git@bitbucket-myAccount2:privateTeam/project.git (fetch)
origin  git@bitbucket-myAccount2:privateTeam/project.git (push)

$ git pull
Enter passphrase for key '/Users/$myUser/.ssh/acc2ssh':
Already up-to-date.

我如何配置它以在xcode和终端上都能工作?

附加问题:如何使终端记住我的密码?

更新

由于混乱,我将添加有关git remote的更多详细信息:

我通过以下方式 checkout git:
$ git clone git@bitbucket-myAccount2:privateTeam/project.git

因为如果我使用bitbucket提供的ssh,它将无法正常工作(访问被拒绝):
$ git clone git@bitbucket.org:privateTeam/project.git
repository access denied.
fatal: Could not read from remote repository.

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

但是Xcode似乎无法识别@Jakuje指出的主机bitbucket-myAccount2。也许我在这里想念什么?

最佳答案

XCode(很可能)不读取您的~/.ssh/config,因为它不是基于OpenSSH的。您应该按原样使用主机名,并提供正确的私钥。

如果仍然选择了另一个(在默认位置),请从默认位置(~/.ssh/id_rsa)将其移开/重命名,并更新~/.ssh/config以反射(reflect)此更改。例如:

Host bitbucket.org
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/id_rsa2

08-27 19:31
查看更多