侧边栏壁纸
博主头像
Ysfun博主等级

一名热爱技术、喜欢折腾的小小程序猿

  • 累计撰写 42 篇文章
  • 累计创建 14 个标签
  • 累计收到 25 条评论

目 录CONTENT

文章目录

如何配置git ssh

Ysfun
2022-06-17 / 0 评论 / 0 点赞 / 73 阅读 / 184 字

1. 检查用户名和邮箱

# 查看用户名
git config user.name
# 查看邮箱
git config user.email
# 配置用户名
git config --global user.name "xxx"
# 配置邮箱
git config --global user.email "xxx"

2. 查看是否配置过SSH Key

ls ~/.ssh
# hyunmin@HyunmindeMacBook-Air .ssh % ls ~/.ssh
# id_rsa      id_rsa.pub  known_hosts

存在id_rsa id_rsa.pub文件即证明已配置过SSH Key

3. 生成SSH Key(秘钥)

ssh-keygen -t -rsa -C "email"

4. GitHub远程仓库添加公钥

  1. 复制~/.ssh/id_rsa.pub文件内容,并粘贴到GitHub->settings->SSH and GPG keys

  2. 检查是否配置成功

ssh -T git@github.com
# 显示如下内容则表示配置成功
# Hi Ysfun! You've successfully authenticated, but GitHub does not provide shell access.
0

评论区