在 GitHub 和 GitLab 添加本机 SSH Public Key 之后,依旧存在不能访问的情况,解决办法如下:

    1. $ touch ~/.ssh/config
    2. $ chmod 600 ~/.ssh/config

    .ssh/config 文件中添加以下内容:

    1. Host github.com
    2. HostName github.com
    3. User git
    4. Port 22
    5. IdentityFile ~/.ssh/id_git
    6. Host git.mygitlab.com
    7. HostName git.mygitlab.com
    8. User git
    9. Port 22
    10. IdentityFile ~/.ssh/id_git

    检测 GitHub 是否可以正常连接:

    1. $ ssh -T git@github.com
    2. Hi mingminyu! You've successfully authenticated, but GitHub does not provide shell access.