How do I access my SSH public key?

2019-03-07 19:13发布

I've just generated my RSA key pair, and I wanted to add that key to GitHub.

I tried cd id_rsa.pub and id_rsa.pub, but no luck. How can I access my SSH public key?

标签: git ssh rsa
17条回答
Luminary・发光体
2楼-- · 2019-03-07 19:51

Here's how I found mine on OS X:

  1. Open a terminal
  2. (You are in the home directory) cd .ssh (a hidden directory)
  3. pbcopy < id_rsa.pub (this copies it to the clipboard)

If that doesn't work, do an ls and see what files are in there with a .pub extension.

查看更多
仙女界的扛把子
3楼-- · 2019-03-07 19:54

The following command will save the SSH key on the clipboard. You only need to paste at the desired location.

cat ~/.ssh/id_rsa.pub | pbcopy
查看更多
够拽才男人
4楼-- · 2019-03-07 19:55

You may try to run the following command to show your RSA fingerprint:

ssh-agent sh -c 'ssh-add; ssh-add -l'

or public key:

ssh-agent sh -c 'ssh-add; ssh-add -L'

If you've the message: 'The agent has no identities.', then you've to generate your RSA key by ssh-keygen first.

查看更多
小情绪 Triste *
5楼-- · 2019-03-07 19:56

After you generate your SSH key you can do:

cat .ssh/id_rsa.pub |pbcopy

which will copy your ssh key into your clipboard.

查看更多
Evening l夕情丶
6楼-- · 2019-03-07 19:57

On terminal cat ~/.ssh/id_rsa.pub

explanation

  1. cat is a standard Unix utility that reads files and prints output
  2. ~ Is your Home User path
  3. /.ssh - your hidden directory contains all your ssh certificates
  4. id_rsa.pub OR id_dsa.pub are RSA public keys, (the private key located on the client machine). the primary key for example can be used to enable cloning project from remote repository securely to your client end point.
查看更多
放我归山
7楼-- · 2019-03-07 19:58

It can be found on this path (default path):

/Users/john/.ssh

john is your Mac username.

查看更多
登录 后发表回答