加载我的私钥以在 Mac 上的 git 中使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1306662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:47:53  来源:igfitidea点击:

Loading my private key for use in git on Mac

gitmacosprivate-key

提问by Ram Rachum

I'm trying to use git on a Mac (I'm a Mac newbie.) I obviously have to load my private key. On my Windows machine I just use pageant and msysgit. How do I load my private key into git on the Mac?

我正在尝试在 Mac 上使用 git(我是 Mac 新手。)我显然必须加载我的私钥。在我的 Windows 机器上,我只使用 pageant 和 msysgit。如何在 Mac 上将我的私钥加载到 git 中?

回答by localshred

Git has a good article on creating and using your private keys here:

Git 有一篇关于创建和使用你的私钥的好文章:

http://github.com/guides/providing-your-ssh-key

http://github.com/guides/providing-your-ssh-key

回答by Jason Goemaat

If you open the key with PuTTY Key Generator, you can export your key in the OpenSSH format. Just copy that to your mac and put it as a file named id_rsain your ~/.sshdirectory (which you'll have to create if you haven't run ssh-keygen).

如果使用 来打开密钥PuTTY Key Generator,则可以以 OpenSSH 格式导出密钥。只需将它复制到您的 mac 并将其作为一个文件命名id_rsa在您的~/.ssh目录中(如果您还没有运行 ssh-keygen,则必须创建该文件)。

Export OpenSSH key

导出 OpenSSH 密钥

If it's not too much trouble though you can just use ssh-keygento create a new key pair and add the new id_rsa.pubpublic key to the account you're accessing. Most online git repositories and ssh hosts (like Winsshd) allow you to link multiple keys to an account.

如果不是太麻烦,您可以使用它ssh-keygen来创建一个新的密钥对并将新的公钥添加id_rsa.pub到您正在访问的帐户中。大多数在线 git 存储库和 ssh 主机(如 Winsshd)允许您将多个密钥链接到一个帐户。

回答by Jamie Macey

I'd say just create a new key. If you're posting to github it's no big deal to push two public keys up, and same for putting it up on another server - it's just another entry in ~/.ssh/authorized_keys.

我会说只是创建一个新密钥。如果你在 github 上发帖,那么推送两个公钥也没什么大不了的,把它放在另一台服务器上也是一样——它只是 ~/.ssh/authorized_keys 中的另一个条目。

The github guide localshred pointed to should have all the directions you'd need.

localshred 指向的 github 指南应该包含您需要的所有方向。