分享交流
合作共赢!

通过密钥访问Github

因为github安全方面更改了用户密码直接操作代码仓库的方式,提高了代码安全性,那么我们访问和操作代码仓库的方式也发生了点变化。如下我们可以采用ssh的方式来操作代码仓库,在此之前需要先创建并导入安全密钥。(如下适用于Linux)

1.生成SSH key

$ ssh-keygen -t ed25519 -C "your_email@example.com"
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com" (如果操作系统不支持Ed25519,执行此命令,二选一)

2.将生成的SSH key添加到ssh-agent中

1)将ssh-agent在后台运行

$ eval "$(ssh-agent -s)"

2) 添加ssh key

$ ssh-add ~/.ssh/id_ed25519

3.将产生的public文件的内容导入之GitHub

只需要打开网页端GitHub,在设置页面找到development设置选项,添加即可。如下:

4.测试连通性:

ssh -T git@github.com

Hi USERNAME! You’ve successfully authenticated, but GitHub does not provide shell access.

参考Github官方文档:

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent?platform=linux

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

赞(0) 打赏
未经允许不得转载:琼杰笔记 » 通过密钥访问Github

评论 抢沙发

评论前必须登录!

 

分享交流,合作共赢!

联系我们加入QQ群

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册