{{tag>git ssh}}
====== 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
Then to clone use that host
git clone git@github-someorg:someuser/repo.git
====== Tested on ======
*
====== See also ======
* [[wiki:clone_remote_ansible_git_module_using_ssh_key|Clone remote repository with ansible git module using ssh key]]
====== References ======