Multiple Github Accounts


#1

Hi there,

I am wondering if it is possible to connect multiple Github accounts (i.e. have multiple ssh keys) to a c9 account. In the account settings, I can see the SSH public key, but can’t use it on github with separate accounts, also there does not seem to be an option to generate a second key on C9.

Any workaround?


#2

You can generate a second ssh key with a new name e.g. ssh-keygen -f ~/.ssh/github_rsa and use it in ~/.ssh/config for github

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile ~/.ssh/github_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

#3

Worked like a charm, Many thanks!.
Just to clarify, I had to configure both keys differently in my ssh and git configs as follow:

Host github.com-firstaccount
  User git
  Port 22
  Hostname github.com
  IdentityFile ~/.ssh/github_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

Host github.com-secondaccount
  User git
  Port 22
  Hostname github.com
  IdentityFile ~/.ssh/github_secondaccountkey_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

And the git config

[remote "origin"]
        url = git@github.com-firstaccount:username1/repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[remote "prod"]
        url = git@github.com-secondaccount:username2/somerepo.git
        fetch = +refs/heads/*:refs/remotes/prod/*

Might be helpful for other people


#4

Hi aubort, I feel like I have the same problem you had
I want to connect different workspaces to different Github accounts
workspace1 - Gh_account1
workspace2 - Gh_account2
I’ve already generated the ssh keys needed for this, however I’m trying the commands shown in here on my workspace terminal and whatever I try, it just doesn’t seem to work

I’d really appreciate it if you could help me