0x00
Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username or password at each visit.
每次 clone 私人项目或者 push 都要输入用户名密码?试试 ssh 吧。
0x01
- 查看
~/.ssh
目录下是否已经有密钥
$ ls -al ~/.ssh
- 生成 ssh key
$ ssh-keygen -t rsa -C "xxx@xxx.xxx" # 可以写上自己的邮箱
# -t 指定密钥类型,默认是 rsa ,可以省略。
# -C 设置注释
📝生成过程中会出现内容,建议直接回车默认设置
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxx/.ssh/id_rsa): [Press enter]
# 设置密码 也可以直接回车
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
# 生成完成
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
f4:3b:xx:85:d6:xx:f0:68:xx xxx@xxx.xxx
- 等待生成完成后,到 github 上添加 ssh key
cat ~/.ssh/id_rsa.pub
⚠️When copying your key, don’t add any newlines or whitespace. 不要加空格或者换行,否则会添加失败
- 最后测试连接
ssh -T git@github.com
如果出现一串字符让你输入 (yes/no) 则直接输入 yes 回车即可
# 成功之后大概是这样子
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.
0x02
封面出处:http://simpledesktops.com/browse/desktops/2019/mar/04/zurich-skyline/