By Andre Perunicic | August 24, 2017
This page describes how to specify which SSH profile to use with git. This can be handy if you have more than one GitHub account and don’t wish to reuse your default SSH key or type in a password every time you push or pull. The commands will be written from the perspective of a GitHub user, but should be easy to adapt to other scenarios as well.
Generate a new SSH key:
ssh-keygen -t rsa -b 4096 -C "email@example.com"
Let’s assume the identity file you created is in
Upload the key to GitHub (link leads to GitHub’s instructions).
SSH will look for profiles in the user’s
~/.ssh/configfile. Add something similar to this to that file:
Host custom Hostname github.com IdentityFile ~/.ssh/id_rsa_custom IdentitiesOnly yes
IdentitiesOnly yesoption is required to prevent the SSH sending the identity file matching the default filename, as is the default. If you have a file named
~/.ssh/id_rsathat will get tried BEFORE your
~/.ssh/id_rsa_customwithout this option.
Associate the remote git repository to your local repo:
git remote add origin git@custom:user/myrepo.git
If starting from scratch, you can just do:
git clone git@custom:user/myrepo.git
From then on, commands like
git push -v origin mastershould work normally without any prompts.
If you got to this page from Google, I hope you found the answer you were looking for. Get in touch with us if you have a data sourcing or analysis task you want done quickly and reliably.
If you enjoyed this article, then you might also enjoy these related ones.
A guide to getting Google Chrome running on RHEL variants.