XCode 4 上 git 的非默认 ssh 密钥对
我想在我正在从事的项目中使用特定的公钥/私钥对。我设法通过将我的密钥对复制到 ~/.ssh/id_rsa 和 ~/.ssh/id_rsa.pub 来使 XCode git repo 工作,但我更愿意将它们命名为 id_github/id_github.pub 或类似的名称(并保留我现有的默认值)密钥对为 id_rsa)。这可以通过使用 ssh 配置文件的 git 命令行轻松实现(http://help.github.com /多个 ssh 密钥/)。
但是我看不到如何使用 XCode 4 执行此操作。我启动它,单击“连接到存储库”,如果我指定 ssh://github:projectname (其中 github 是包含我的用户名的 ssh 配置条目),它会告诉我“主机无法访问”。
有谁知道如何做到这一点,或者在 XCode 中是否可以做到这一点?
I'd like to use a specific public/private key pair on a project I am working on. I managed to get the XCode git repo working by copying my keypair to ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub but I would prefer to name them id_github/id_github.pub or something similar (and keep my existing default keypairs as id_rsa). This is easily achieved with the git commandline using ssh config file (http://help.github.com/multiple-ssh-keys/).
However I cannot see how to do this with XCode 4. I start it up, click "Connect to a repository" and if I specify ssh://github:projectname (where github is an ssh config entry containing my username) it tells me that the "Host is unreachable".
Does anyone know how to do this or if it is at all possible in XCode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要为 github 创建主机配置。
在 ~/.ssh/config 中创建一个条目,它看起来像这样:
通过或在 Xcode 中从 CLI 检出存储库
然后,您可以使用相同的 URL 签名
。另一方面,您还可以使用端口主机配置声明非标准端口。这允许您在非标准端口上通过 ssh 使用 scp。
编辑
我确实注意到的一件事是,有时 Xcode 声称第一次单击时无法访问它,但通过单击“后退”并重试......它会通过。在我最近设置的存储库中注意到了这一点。
You need to create a host configuration for github.
Create an entry in ~/.ssh/config, it would look something like this:
You can then check out repositories from the CLI via
Or in Xcode using the same URL signature.
On a side, you can also declare a non-standard port using the Port host config. This allows you to use scp over ssh on non-standard ports.
edit
One thing I did notice, is that sometimes Xcode claims it is unreachable on the first click, but by clicking "back" and trying again…it goes through. Noticed this on the most recent repo I set up.
您应该指定 url,
而不是指定的 ssh。
希望这有帮助。
You should be specifying the url with
instead of the ssh one you are specifying.
Hope this helps.
最合理的解决方法是将多个密钥上传到 github。我问问题时并没有意识到这是可能的,但它为我解决了问题。
当然,只使用 git 命令行总是最佳的:)
The most reasonable workaround for this is just to upload multiple keys to github. I didn't realize that was possible at the time I asked the question but it solves the problem for me.
Of course, just using the git command line is always optimal :)