ssh - github 使用ssh key的注意事项: 一个ssh pub key 只能对应一个github user
访问量: 1
refer to: https://docs.github.com/en/authentication/connecting-to-github-with-ssh
1. 生成ssh key.
2. 如果有多个ssh key的话,修改 ~/.ssh/config
Host * ServerAliveInterval 60 ServerAliveCountMax 3 # 第一个服务器配置 Host bc_server HostName 158.255.2.21 User root IdentityFile /root/.ssh/id_rsa_for_bc # 第一个服务器配置 Host bc_server2 HostName 8.217.127.107 User root IdentityFile /root/.ssh/id_rsa_for_bc Host github.com HostName github.com IdentityFile /root/.ssh/id_ed25519_for_excxxx IdentitiesOnly yes
3. 使用命令来验证,某个key 是对应github哪个用户。(注意:github不允许2个用户共用一个ssh pub key)
ssh -T git@github.com
Hi Henniexx! You've successfully authenticated, but GitHub does not provide shell access.
4. git clone git@xxx 就可以了。
如果遇到这个问题的话:那就是多个用户共用了一个ssh pub key, 使用ssh -T 就知道具体是哪个用户了。
Cloning into 'app_android'... ERROR: Repository not found. fatal: Could not read from remote repository. Please make sure you have the correct access rights