Linux操作系统配置git的ssh

系统:Ubuntu20.04LTS

安装git:

sudo apt install git

配置git:

添加全局git用户和邮箱

git config --global user.name "用户名"

git config --global user.email "邮箱"

查看用户名和邮箱是否有误

git config --list

生成密钥:

ssh-keygen -t rsa -b 4096 -C "邮箱"

执行上面的命令后按三次Enter键,选择默认即可

添加ssh密钥到ssh代理,~/.ssh/id_rsa 是密钥文件:

ssh-add ~/.ssh/id_rsa

如果提示:Could not open a connection to your authentication agent表示ssh代理没有启动,执行下面的命令:

eval "$(ssh-agent -s)"

再次执行添加到ssh代理指令,输出added后面加邮箱地址表示成功。

将公钥添加到GitHub中:

Settings----->SSH and GPG keys----->Authentication keys----->New SSH keys

将公钥复制过去。

测试,输入下面的指令,如果输出:You've successfully authenticated, but GitHub does not provide shell access表示设置SSH成功:

ssh -T git@github.com

相关推荐
A_Lonely_Cat6 小时前
记一次 GitHub 幽灵协作者大清洗:强制重写 Git 历史与穿透 CDN 缓存实践
git·github
tntxia18 小时前
linux curl命令详解_curl详解
linux
扛枪的书生21 小时前
Linux 网络管理器用法速查
linux
顺风尿一寸1 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
XIAOHEZIcode1 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫1 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux
和你看星星2 天前
Git rerere:让重复冲突只解决一次
git
AlfredZhao3 天前
生产环境里,为什么不建议把普通端口直接暴露到公网?
linux·https·443·80
戴为沐4 天前
Linux内存扩容指南
linux
zylyehuo5 天前
Linux 彻底且安全地删除文件
linux