- 首先用 ssh -vT git@github.com 测试一下,会去你用户目录下面找公钥文件, 有打印出下面的信息,这说明/User/用户名/.ssh/ 下面去寻找公钥文件,当前用户目录下面的确没有公钥文件
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).
- 执行: cd /Users/xxx/.ssh/
- 执行: ssh-keygen -t rsa -b 4096 -C “Git 上关联的email”
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/chenxuan/.ssh/id_rsa):
点击回车
/Users/xxx/.ssh/id_rsa already exists
Overwrite (y/n)
输入 y
生成id_rsa.pub 文件后, 执行 vi id_rsa.pub 打开文件, 复制文件内容到GitHub --> settings–>SSH and GPG Keys --> new SSH key
然后保存
- 重新执行 ssh -vT git@github.com , 成功提示:
You've successfully authenticated, but GitHub does not provide shell access.