This is an old revision of the document!
Table of Contents
git pull via ssh public key
If using for example 'myuser' user but with a custom ssh key name i.e. myuser_github and not id_rsa you will get an error if trying to run the following command:
myuser@host:~/my-user$ git clone git@github.com:someuser/repo.git . Cloning into '.'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
Fix this by editing .ssh/config to this:
Host github.com HostName github.com User git IdentityFile ~/.ssh/myuser_github
Use different host
You can use a custom hostname as well, e.g.
Host github-someorg HostName github.com IdentityFile ~/.ssh/myuser_github
When using Vim vim-fugitive plugin, the GBrowse command can only work with above if it is set in ~/.ssh/config file, not in ~/.ssh/ssh_config.d directory.
Then to clone use that host
git clone git@github-someorg:someuser/repo.git
SSH will try all of the keys it sees, so the ones provided by any running ssh-agent and the file specified above in IdentityFile. This might not be what you want, because if the ssh key from the ssh-agent is used by your different github user for different repos.
To explicitly use only the key in IdentityFile also add IdentititesOnly yes
to the configuration.