Skip to content

Instantly share code, notes, and snippets.

@jlainezs
Created December 16, 2022 19:23
Show Gist options
  • Save jlainezs/72c464a1e3c1f897d348e36e142eb42b to your computer and use it in GitHub Desktop.
Save jlainezs/72c464a1e3c1f897d348e36e142eb42b to your computer and use it in GitHub Desktop.
Git things

Using several accounts on the same git service with ssh

We need to create an alternative certificate for the second account (pk stored in id_rsa.myotheridentity).

WARNING: when generating the new credentials take care not to overwrite any id_rsa and id_rsa.pub files you may have in ~/.ssh

Edit ssh config in ~/.ssh/config . Create it if not exists.

Host gitlabmyproject
    Hostname gitlab.com
    IdentityFile ~/.ssh/id_rsa.myotheridentity
    IdentitiesOnly yes

Clone the repo:

git clone git@gitlabmyproject:myrepo.git

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment