Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

记录github push -f 提示Permission denied (publickey).的问题 #40

Open
xxholly32 opened this issue Mar 23, 2020 · 1 comment
Open

Comments

@xxholly32
Copy link
Owner

PS:如果忘了Git密码,放弃如何修改,选择删除后重新创建一个新的SSH密钥吧。据调查Git为了保证安全并没有重新修改密码的功能

1、首页:查看本地是否有.ssh文件
找到 Git Bash 打开后 运行 cd ~/.ssh 查看是否有该文件
如果本地有ssh密钥的话会有id_rsa、id_rsa.pub、known_hosts等文件。
如果没有的话运行上步骤命令就会找不到文件的提示
2、也可以删除ssh
复制并运行 rm -rf ~/.ssh/* 把现有的ssh key都删掉,这句命令行如果你多打一个空格,可能就要重装系统了,建议复制运行。
3、运行 ssh-keygen -t rsa -b 4096 -C “你的邮箱” ,注意填写你的真实邮箱。
4、按回车三次
5、运行 cat ~/.ssh/id_rsa.pub ,得到一串东西,完整的复制这串东西
6、打开GitHub->点击头像->setting->SSH adn GPG keys->New SSh key
7、输入你的title、把刚才复制的那段粘贴到key中保存
8、运行 ssh -T [email protected] ,你可能会看到这样的提示。
9、输入yse
10、然后如果你看到 Permission denied (publickey). 就说明你失败了,请回到第 1 步重来,是的,回到第 1步重来;
如果你看到 Hi FrankFang! You’ve successfully authenticated, but GitHub does not provide shell access.
那就说明你成功了
————————————————
版权声明:本文为CSDN博主「stormyk」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/stormyk/article/details/89362078

@xxholly32
Copy link
Owner Author

配置多个sshkey

为github生成一对秘钥ssh key

ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/gitlab_id-rsa/zhangsan_github

为gitlab生成一对秘钥ssh key

ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/gitlab_id-rsa/zhangsan_gitlab

为gitlab生成另一对秘钥ssh key

ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/gitlab_id-rsa/lisi_gitlab

在ssh下面加个config(无后缀文件),内容如下,不要留空格

# gitlab
Host gitlab.com
HostName gitlab.com
User zhangsan_github
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_id-rsa/zhangsan_github
# github1
Host gitlab.com
HostName gitlab.com
User zhangsan_gitlab
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id-rsa/jxl-taylor
# github2
Host gitlab.com
HostName gitlab.com
User lisi_gitlab
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id-rsa/lisi_gitlab

GITHUB/GITLAB添加多个SSH KEY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant