git-ssh 配置和使用
git config --global user.name "songkunpeng"
git config --global user.email "your.email@example.com"
ssh-add -K ~/.ssh/id_rsa
-
设置Git的user name和email:(如果是第一次的话)
$ git config --global user.name "humingx"
$ git config --global user.email "humingx@yeah.net
2、生成密钥
$ ssh-keygen -t rsa -C "humingx@yeah.net" (和git的email 保持一致)
3、添加密钥到ssh-agent
确保 ssh-agent 是可用的。ssh-agent是一种控制用来保存公钥身份验证所使用的私钥的程序,其实ssh-agent就是一个密钥管理器,运行ssh-agent以后,使用ssh-add将私钥交给ssh-agent保管,其他程序需要身份验证的时候可以将验证申请交给ssh-agent来完成整个认证过程。
# start the ssh-agent in the background
eval "$(ssh-agent -s)"
Agent pid 59566
添加生成的 SSH key 到 ssh-agent。
$ ssh-add ~/.ssh/id_rsa
4、登陆Github, 添加 ssh 。
把id_rsa.pub
文件里的内容复制到这里
5、测试:
$ ssh -T git@github.com
你将会看到:
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
选择 yes
Hi humingx! You've successfully authenticated, but GitHub does not provide shell access.
如果看到Hi
后面是你的用户名,就说明成功了。
6、修改.git
文件夹下config
中的url
。
修改前
[remote "origin"]
url = https://github.com/humingx/humingx.github.io.git
fetch = +refs/heads/*:refs/remotes/origin/*
修改后
[remote "origin"]
url = git@github.com:humingx/humingx.github.io.git
fetch = +refs/heads/*:refs/remotes/origin/*
7、发布
[图片描述](https://segmentfault.com/img/bVlgoT)
``
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通