gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 14:07:37 25 4
gpt4 key购买 nike

由于我客户的隐私要求,我必须创建多个帐户来访问不同的 git。在一些帮助下,我在目录 ~/.ssh 中创建了文件 config 和多个 ssh key 。 使用终端,我已经能够对 git 执行各种操作。但是,如果我使用 XCode 执行这些操作,它会显示无法验证

xcode failed

这是~/.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.pubacc2ssh , acc2ssh.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 远程的更多详细信息:

我正在通过以下方式 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.

但正如@Jakuje 指出的那样,Xcode 似乎无法识别主机 bitbucket-myAccount2。也许我在这里遗漏了什么?

最佳答案

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

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

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

关于xcode - 多个 git 帐户不适用于 Xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43864675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com