系统环境:ubuntu18.04
1.设置SSH
cd ~/.sh
sudo ssh-keygen -t rsa -C "你的注册邮箱" #生成ssh
# 然后连按三下回车
sudo gedit id_rsa.pub #打开id_rsa.pub文件,并把内容复制到剪切板
登录到github打开设置;

选择SSH and GPG keys,点New SSH

然后配置SSH,点击Add SSH key完成。

2.配置SSH
cd ~/.ssh #进入ssh目录
sudo touch config #新建ssh的配置文件
sudo gedit config #修改ssh的配置文件
sudo chmod 600 config #添加权限
config文件的内容:
Host github.com
User 你的注册邮箱
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
测试
sudo ssh git@github.com
看到如下图,说明配置成功

3.修改_config.yml
修改deploy下的repo属性
deploy:
type: git
repo: git@github.com:你的name/你的username.github.io.git
branch: master


参考博客:
https://zhuanlan.zhihu.com/p/26625249
https://blog.youkuaiyun.com/MBuger/article/details/70226712
https://blog.youkuaiyun.com/hhgggggg/article/details/77853665

本文详细介绍了在 Ubuntu 18.04 系统环境下,如何通过 SSH 连接到 GitHub 的过程。从生成 SSH 密钥对开始,到配置 SSH 密钥,最后测试连接确保一切正常。同时,还提供了修改 _config.yml 文件中 deploy 部分的 repo 属性的方法,以便于部署项目。
1679

被折叠的 条评论
为什么被折叠?



