GitHub SSH设置与Permission denied问题解决方法 |
您所在的位置:网站首页 › git权限不足 › GitHub SSH设置与Permission denied问题解决方法 |
1.配置个人信息
git config --global user.name "你的username"
git config --global user.email "你的邮箱"
2.生成公私密钥对
ssh-keygen -t rsa -C "邮箱地址"
# eg:
$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
# 这里需要注意 如果使用默认路径和名字为id_rsa则直接按下回车就可以,如果自定义其他名字还需要将前面的路径补全
# 我这里就是自定义的名字叫github
Enter file in which to save the key (/c/Users/Vergil/.ssh/id_rsa): /c/Users/Vergil/.ssh/github
# 直接回车
Enter passphrase (empty for no passphrase):
# 直接回车
Enter same passphrase again:
Your identification has been saved in /c/Users/Vergil/.ssh/github
Your public key has been saved in /c/Users/Vergil/.ssh/github.pub
The key fingerprint is:
SHA256:dgi9LeQ2qNnN/3lezjzbfF6Lam0TsVO0QGMpK23mY7c [email protected]
The key's randomart image is:
+---[RSA 3072]----+
| .+. |
| . ..o.. |
| . o . o o .|
| = = = . o |
| . S B + |
| + = + + = |
| o . o . + + o|
| . . EoB=|
| oo=+o+@|
+----[SHA256]-----+
3.在github中设置ssh
在设置中找到SSH and GPG keys,之后点击右上角New SSH key Title里随意填写自己想起的名字就好 Key里面填写刚才生成好的公钥里的内容 填写后点击 Add SSH key 即可 4.测试 ssh [email protected] # eg: $ ssh [email protected] PTY allocation request failed on channel 0 Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.看到欢迎语就证明配置成功了。 5.Permission denied 解决在ssh测试或者后续通过git pull或push会出现Permission denied问题 $ ssh [email protected] [email protected]: Permission denied (publickey).由于ssh默认找文件名为id_rsa的私钥,如果自定义别的私钥名,则多半是由于ssh配置没有找到自定义私钥的位置 windows10: 进入 C:/Users/你的用户名/.ssh 文件夹linux/mac: 进入 ~/.ssh 文件夹在这个目录下编辑config文件,如果没有则自行创建,不需要加后缀 写入 Host github.com HostName github.com IdentityFile ~/.ssh/github # 这里填写你的私钥路径保存后再次执行测试命令,即可发现已经可以连接上了 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |