Configuring your identities
Do you need acces to diffent repositories, public, private or private in your organization? configure your identities to access the specific host:
Modify the ssh config
$ vi ~/.ssh/config
Example config:
Host alter.github.com
HostName github.com
User git
IdentityFile /home/alter-ego/.ssh/alter_github.id_rsa
IdentitiesOnly yes
Host ego.github.com
HostName github.com
User git
IdentityFile /home/alter-ego/.ssh/ego_github.id_rsa
IdentitiesOnly yes
Host gitlab.com
HostName gitlab.com
User git
IdentityFile /home/alter-ego/.ssh/alter-ego_gitlab.id_rsa
IdentitiesOnly yes
Clean or start ssh agent and add private keys:
# Start agent, if not running
$ eval `ssh-agent -s`
# delete all cached keys before
$ ssh-add -D
# Add defaul key (~/.ssh/id_rsa)
$ ssh-add
# Add alter key from example
$ ssh-add ~/.ssh/alter_github.id_rsa
# List saved keys
$ ssh-add -l
4096 SHA256:XXXXXXX+YYYYYYYYY adrianescutia@mail.com (RSA)
4096 SHA256:ZZZZZZZ/AAAAA+h0+FHo aescutias@mail.com (RSA)
To automatically start ssh-agent and allow a single instance to work in multiple console windows, see Start ssh-agent on login, or even better, an easy solution with zsh.
In your local Git repo, add the host as specified in Host
ssh config file:
cd /my/project/dir
git remote add origin git@alter.github.com:myproject/repo.git
References:
Feedback
For any feedback or request, don't hesitate, open an `issue` and let me know. Don't be shy.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.