github配置

发布时间 2023-03-27 03:06:11作者: LinXiaoshu

如何与github相连

shell中输入

ssh-keygen -t rsa -C "youremail"

连续回车,成功后提示 our identification has been saved in xxx

进入github,添加密钥.随后在本地shell进行验证:

ssh -T git@github.com

可能在此之前要进行:

ssh-add id_rsa

然后在已经init的目录下

git remote add origin git@github.com:username/reponame.git

这个指令的含义是:将远程的repo在本地称为origin.

提交时使用(其中前者为远程分支名,后者为本地分支名.)

git push -u origin main

20230327更新

今天想提交一下做的minilisp,又是老问题无法链接github.

照上述方法重新生成,居然不行!
powershell报错

(base) PS C:\Users\xxx> ssh -T git@github.com
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in C:\\Users\\gdx/.ssh/known_hosts to get rid of this message.
Offending RSA key in C:\\Users\\gdx/.ssh/known_hosts:1
RSA host key for github.com has changed and you have requested strict checking.
Host key verification failed.

经查找,在这里找到了原因,即3月23日,github更新了他们服务器的ssh host key.NMD!
按照网站说的,执行

ssh-keygen -R github.com

即在/.ssh/known_hosts中移除原有github key,并手动添加

github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=

即可.