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条回答
不美不萌又怎样
2楼-- · 2019-03-07 19:39

If you're on Windows use the following, select all, and copy from a Notepad window:

notepad ~/.ssh/id_rsa.pub  

If you're on OS X, use:

pbcopy < ~/.ssh/id_rsa.pub
查看更多
在下西门庆
3楼-- · 2019-03-07 19:39

Use:

# sudo su
# cd /home/user/.ssh
.ssh# gedit id_rsa.pub

Then copy the entire file without any spaces. Click your icon at the top right of the GitHub page, go to settings, and add ssh.

Paste the copy into the space. It may prompt for your GitHub password. Enter it. Save.

查看更多
ら.Afraid
4楼-- · 2019-03-07 19:40

cat ~/.ssh/id_rsa.pub or cat ~/.ssh/id_dsa.pub

You can list all the public keys you have by doing:

$ ls ~/.ssh/*.pub

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

Copy the key to your clipboard.

$ pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

Warning: it's important to copy the key exactly without adding newlines or whitespace. Thankfully the pbcopy command makes it easy to perform this setup perfectly.

And you can paste it wherever you need.

To get a better idea of the whole process, check this: Generating SSH Keys.

查看更多
Summer. ? 凉城
6楼-- · 2019-03-07 19:45

On a Mac, you can do this to copy it to your clipboard (like cmd + c shortcut)
cat ~/Desktop/ded.html | pbcopy
pbcopy < ~/.ssh/id_rsa.pub

and to paste pbpaste > ~Documents/id_rsa.txt

or, use cmd + v shorcut to paste it somewhere else.

~/.ssh is the same path as /Users/macbook-username/.ssh
You can use Print work directory: pwd command on terminal to get the path to your current directory.

查看更多
霸刀☆藐视天下
7楼-- · 2019-03-07 19:49

In UBUNTU +18.04

         ssh-keygen -o -t rsa -b 4096 -C "email@example.com" 

And After that Just Copy And Paste

         cat ~/.ssh/id_rsa.pub 

or

         cat ~/.ssh/id_dsa.pub
查看更多
登录 后发表回答