Using Git via SSH and a non-standard userΒΆ

Use case: You currenty use GitHub or another git service via ssh, and have a defualt user configured in your ~/.gitconfig and uses your ~/.ssh/id_rsa key for connecting. So far so good.

Now, you want to use a separate user for certain repositories, for some reason. Here it is an explanation on how to do this.

First, add something like this to ~/.ssh/config:

Host github-otheruser
    IdentityFile ~/.ssh/id_rsa-otheruser
    User git
    Port 22

The, just clone the repository and configure user in one command:

git clone github-otheruser:otheruser/myrepo \'Other User' [email protected]
comments powered by Disqus

Previous topic

Debian: registering an apt repository key

Next topic

GitLab: misc

This Page