I can manage multiple SSH keys for different GitHub accounts so that I can access multiple accounts and projects, each with different credentials. However, is it possible for me to work on two different projects on two different github accounts (push and pull) in the same RStudio? I searched online but could not find an answer. I have related SSH keys in my folder. However, I cannot change SSH RSA key in Global Options of RStudio since it always puts the file ~/.ssh/id_rsa
. But I also have another key for my another Github account ~/.ssh/id_rsa_SECOND
. I would appreciate any help! Thank you!
EDIT: My config file has,
Host me.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile Clone ~/.ssh/id_rsa
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_SECOND
which tells me to use me.github.com instead of github.com as host for repositories in the first Github account (with identity ~/.ssh/id_rsa) AND to use github.com for repositories in the second Github account (with identity ~/.ssh/id_rsa_SECOND). However, when I clone a repository in my personal account , using git@ **me**.github.com:username/hugo-academic.git
does not work.
This is an old question, but in case anybody else lands here with this problem, the solution (for me) is to include the github username in each block in ~/.ssh/config. As in:
# USERNAME-1 at github:
Host github.com-1
HostName github.com
User USERNAME-1
IdentityFile ~/.ssh/id_rsa_1
IdentitiesOnly yes
# USERNAME-2 at github:
Host github.com-2
HostName github.com
User USERNAME-2
IdentityFile ~/.ssh/id_rsa_2
IdentitiesOnly yes
In the github URL, change "github.com" to "github.com-1" or "github.com-2" as needed, so for example, you'd clone with:
git clone [email protected]:USERNAME-1/foo.git
instead of:
git clone [email protected]:USERNAME-1/foo.git
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With