SSH 传输

问题

git ·push 时出现问题

1
fatal:Authentication failed for‘https://git ...

原因/解决:

github 政策改变,在填写 password 时要使用 token

https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

image-20231108223535267

优化

但是使用 https 协议每次都要输入 token

改为 ssh 传输

参考

https://blog.csdn.net/qq_41726670/article/details/124389683

查看现在使用什么协议传输

1
2
3
4
git remote -v
origin https://github.com/用户名/仓库 (fetch)
origin https://github.com/用户名/仓库 (push)

可以看出来使用了 https 协议

修改为 ssh 传输(前提事先生成 ssh 密钥)

1
2
git remote set-url origin git@github.com:用户名/仓库