Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git ssh秘钥 #31

Open
Vibing opened this issue Nov 27, 2020 · 0 comments
Open

git ssh秘钥 #31

Vibing opened this issue Nov 27, 2020 · 0 comments

Comments

@Vibing
Copy link
Owner

Vibing commented Nov 27, 2020

使用ssh-keygen命令生成 ssh 秘钥:

➜  ~ ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/aa/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/aa/.ssh/id_rsa.
Your public key has been saved in /Users/aa/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:vJ43VKHgqjiQVorBY4tZL6f2wXX6V8l6F/DjN8iLJ8o aa@AAdeMacBook-Pro
The key's randomart image is:
+---[RSA 3072]----+
|                 |
|        .   .    |
|.      . . . .   |
|.+..   .. . o    |
|+==.  ..S  o +   |
|*+..o..o .. + +  |
|.. =o.. .. o...o |
|  = .. o..=.o+o..|
| . o.   +E.+oo...|
+----[SHA256]-----+

查看刚才生成的秘钥:

➜  ~ ls ~/.ssh
id_rsa      id_rsa.pub  known_hosts
  • id_rsa: 密钥文件
  • is_rsa.pub: 公钥文件

一般 ssh 需要公钥,查看公钥:

➜  ~ cat ~/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDJthVQyVKP+4gGIyTH9zrd/0Ak2n0PAnHED71VZx/HgdOue/HfzXVgfO2pLnq/rzO9W/GUEOetdOwyhDRsB/x1bFGvYRn6dKXQh8I949pc4uj5jHG6s0eiKG3e4Kahckxj8y0LxQ1VG+erYQ05FeXo/27iFXRYe4At13GS2QHQ+a3Lbh6O0whl2qITzOWO8IIH3g1HLkjlPL8cmOz1gpgcqh1LQ/HjERIlxDiFtn1Y8J/G9R1RGh21lNaRbXX7rzGUfuaToB1kifNcz8VzDbpNZgXl8BFuFLfHMcpay113Y1kg588/ESh166MPDQngHp1YjkZLNgDwQsXJ+qyTjnfi3kOo56loCr+y653BtJqSa86f7n/tTdKw7lCicRhDzrFHRNV9lBApIp7dAfdIV03HuKHJ5JRBtCKNRN/mziWaxi0oE1IZdPK76Ehzh0FuPRpe8fbTc8qir6xYnMGOthmMcOtwAoWi+Lcb4JIekRcLsJo9F05xUzvNj3KxwSteehU= aa@AAdeMacBook-Pro

以 github 为例,进入用户-> settings -> SSH and GPG keys,新建一个 ssh key,将刚才的 ssh 公钥复制进去即可

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant