git: 配置github的公钥

一,生成公钥

未生成:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

已生成:

cat ~/.ssh/id_rsa.pub

二,在github上添加公钥

 Settings → SSH and GPG keys → New SSH key,

如图:

image

测试连接到git服务器:

$ ssh -T git@github.com
Hi liuhongdi! You've successfully authenticated, but GitHub does not provide shell access.

三,使用url:

选择ssh的地址

image

$ git remote set-url origin git@github.com:username/repository.git 

 

posted @ 2026-04-25 10:50  刘宏缔的架构森林  阅读(7)  评论(0)    收藏  举报