在 mac 上生成了用于 git 的公共 rsa 密钥,但找不到它?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2374021/
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 04:07:31  来源:igfitidea点击:

Generated public rsa key on mac for use with git, but can't locate it?

gitmacosposixssh-keysopenssh

提问by user246114

I'm on mac os X (new to it) and need to generate a public rsa key for use with git (think I got that right). I'm following the directions here:

我在 mac os X 上(刚接触它)并且需要生成一个公共 rsa 密钥以与 git 一起使用(认为我是对的)。我正在按照这里的说明进行操作:

http://help.beanstalkapp.com/faqs/git/generating-and-adding-ssh-keys-on-mac-os-x

http://help.beanstalkapp.com/faqs/git/generating-and-adding-ssh-keys-on-mac-os-x

and have generated the key named (id_rsa.pub) in my home directory, but I don't see it there when I do ls, or when I view through the file explorer gui. Is it like a hidden file or something? How can I see it? I need to email the public key to someone,

并在我的主目录中生成了名为 (id_rsa.pub) 的密钥,但是当我执行 ls 或通过文件资源管理器 gui 查看时我没有在那里看到它。是隐藏文件之类的吗?我怎么能看到呢?我需要将公钥通过电子邮件发送给某人,

Thanks

谢谢

回答by jasedit

By default it stores the key in the ~/.sshdirectory, which is hidden.
All directories that start with a period are hidden, but can be seen either by directly naming them or by specifying the ., as in:

默认情况下,它将密钥存储在~/.ssh隐藏的目录中。
所有以句点开头的目录都是隐藏的,但可以通过直接命名或指定 来查看.,如下所示:

ls .*

So to get a copy, you can type cp ~/.ssh/id_rsa.pub ~/and it'll appear in your home directory.

因此,要获取副本,您可以键入cp ~/.ssh/id_rsa.pub ~/,它会出现在您的主目录中。

回答by Baraa Al-Bourghli

you can directly copythe key to the clipboard by executing this command in your terminal

您可以通过在终端中执行此命令直接密钥复制到剪贴板

cat ~/.ssh/id_rsa.pub | pbcopy

回答by Pritam Banerjee

The following command can be used to copy the public keyin your clipboard.

以下命令可用于复制剪贴板中的公钥

pbcopy < ~/.ssh/id_rsa.pub