Fixing SSH Access Denied for Git SSH remotes

This same process is true for Gitlab, Github, Bitbucket, etc.


If you have more than about 5 SSH keys on your PC in ~/.ssh/, you need to setup your ~/.ssh/config file so that SSH to github.com (or other SSH server) uses the correct SSH Public Key the first connect try.

  1. add this to ~/.ssh/config

     Host github.com
         Hostname github.com
         User git
         Port 22
         IdentitiesOnly yes
         PubKeyAuthentication yes
         IdentityFile ~/.ssh/mygit
    

    where mygit is the key you created following the process (without ssh-agent).

  2. switch your remote URL to SSH

Categories: ,

Updated:

Leave a Comment