为git配置ssh密钥验证连接github

1.安装git

sudo apt update && sudo apt install git

2.打开Powershell或者Linux终端,执行命令生成密钥

ssh-keygen -C '[github邮箱]' -t rsa -b 4096

中间三个回车跳过

3.在当前路径下会看到一个 id_rsa.pubid_rsa 其中 .pub 结尾的是公钥,需要保存到github的服务端. 打开 id_rsa.pub

cat id_rsa.pub

复制上面看到的内容,进入 SSH and GPG keys (github.com) ,登录github, 点 New SSH key ,第一个框自己填用于区分公钥的名字,并将刚才复制的内容粘粘到第二个框,点 Add SSH key

4.配置git用户

git config --global user.name "[github用户名]"
git config --global user.email "[github邮箱]"

5.测试是否能够连接验证github

ssh -T [email protected]

第一次连接,让你确认输入 yes 并回车,可以看到出现了类似 Hi IYATT-yx! You've successfully authenticated, but GitHub does not provide shell access. 文字

猜你喜欢

转载自blog.csdn.net/weixin_45579994/article/details/112382018