生成秘钥
ssh-keygen -t rsa -C test@yeah.net
代码参数含义:
-
-t
指定密钥类型,默认是 rsa ,可以省略; -
-C
设置注释文字,比如邮箱; -
-f
指定密钥文件存储文件名;
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/angela/.ssh/id_rsa): <==密钥文件默认存放位置,按Enter即可
Enter passphrase (empty for no passphrase): <== 输入密钥锁码,或直接按 Enter 留空
Enter same passphrase again:<== 再输入一遍密钥锁码
Your identification has been saved in /Users/angela/.ssh/id_rsa.<== 生成的私钥
Your public key has been saved in /Users/angela/.ssh/id_rsa.pub.<== 生成的公钥
The key fingerprint is:
SHA256:K1qy928tkk1FUuzQtlZK+poeS67vIgPvHw9lQ+KNuZ4 test@yeah.net
The key's randomart image is:
+---[RSA 3072]----+
|.+ . o |
|o * B |
| + = = |
|. B o . |
|.O.o . .S |
|o++* ..oo. |
|ooB = .o.o |
|=+ o *.E. |
|=o. ..=. |
+----[SHA256]-----+
此时在.ssh目录下得到了两个文件:id_rsa(私有秘钥)和id_rsa.pub(公有密钥)。
将 rsa.pub 中的内容添加至远端 github 仓库中,即可使用 ssh 访问 github。
网友评论