cd ~/.ssh
ssh-keyen -t rsa -C "xxxxxx@xxx.com" -f "id_rsa_gitee"
ssh-keyen -t rsa -C "xxxxxx@xxx.com" -f "id_rsa_github"
完成后,目录内容如下:
-rw------- 1 lambda lambda 1679 Jun 14 10:51 id_rsa_gitee
-rw-r--r-- 1 lambda lambda 400 Jun 14 10:51 id_rsa_gitee.pub
-rw------- 1 lambda lambda 1679 Apr 1 13:44 id_rsa_github
-rw-r--r-- 1 lambda lambda 399 Apr 1 13:44 id_rsa_github.pub
-rw-r--r-- 1 lambda lambda 2434 Jun 14 11:05 known_hosts
在.ssh目录下创建config文件,添加如下内容:
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
命令:
ssh -T git@gitee.com
# 或
ssh -T git@github.com
成功:
Hi xxxx! You've successfully authenticated, but GITEE.COM does not provide shell access.
在测试环节,有时会出现如下错误:
# Linux
Bad owner or permissions on /home/lambda/.ssh/config
# Windows
Bad owner or permissions on C:\\Users\\Ran\\.ssh\\config
解决办法
sudo chmod 600 ~/.ssh/config
1. 查看PATH环境中是否存在C:\Windows\System32\OpenSSH\ssh.exe <br>
2. 将C:\Windows\System32\OpenSSH\ssh.exe改成C:\Program Files\Git\usr\bin\ssh.exe <br>
https://blog.csdn.net/weixin_36191602/article/details/80946242
https://stackoverflow.com/questions/49926386/openssh-windows-bad-owner-or-permissions
原文:https://www.cnblogs.com/lambdaRan/p/11022857.html