Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Multiple GitHub accounts(Using Eclipse with projects from different GitHub accounts)
Multiple GitHub accounts [message #1850670] Sun, 13 March 2022 21:40 Go to next message
Sam Hobbs is currently offline Sam HobbsFriend
Messages: 12
Registered: July 2010
Junior Member
Should I be able to use Eclipse with projects from different GitHub accounts? Can I do that in the same workspace? Do I use a different SSH key for each GitHub account?

I have the SamHobbsOrg account for my Sam Hobbs's Web Site for non-technical content. I used Eclipse to create (convert to) that website as it currently exists. I am using SSH for the security.

I have the SimpleSamples account for technical content, hosted by WinHost. I want to use Eclipse to also convert that to a GitHub Pages site and use that for SimpleSamples.

Using Eclipse (actually Egit, right?) I cloned SimpleSamples/simplesamples.github.io. As best as I can see, I replaced everything for the other repository with this repository; the account, the repository name, the SSH key and all I can see. I have created a SSH key and stored that in GitHub. When I try to push a change I get:
https://1drv.ms/u/s!AvUMEnyDQiQYg4NZB4I1gYcDa-WaXA?e=Q5E0yb

The SSH keys for each account are different but I am not sure how they are stored locally. Locally they are both stored in:
C:\Users\sam\.ssh

and that concerns me. In Window | Preferences in General | Network Connections | SSH2 the Private Keys are:
id_dsa,id_rsa,id_rsa

Since id_rsa is repeated that is suspicious.

I have made some changes and now when I try to push it says it cannot connect to any repository.

[Updated on: Sun, 13 March 2022 21:55]

Report message to a moderator

Re: Multiple GitHub accounts [message #1850682 is a reply to message #1850670] Mon, 14 March 2022 09:15 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 497
Registered: August 2016
Senior Member
I think you can get that to work using aliases in ~/.ssh/config. Never tried this, but something like the following should work:
Host samhobbsorg
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa_samhobbsorg
IdentitiesOnly yes

Host simplesamples
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa_simplesamples
IdentitiesOnly yes

The "Host" lines define two different aliases for github.com.

Then use remote URIs ssh://samhobbsorg/SamHobbsOrg/SamHobbsOrg.github.io.git and ssh://simplesamples/SimpleSamples/simplesamples.github.io.git .

If you want the remote URIs to remain ssh://git@github.com/..., you could do more trickery via the git config. Include in your git user config the following
[url "ssh://samhobbsorg/SamHobbsOrg/"]
   insteadOf = ssh://git@github.com/SamHobbsOrg/
[url "ssh://simplesamples/SimpleSamples/"]
   insteadOf = ssh://git@github.com/SimpleSamples/

With that, you should even be able to use the remote URIs ssh://git@github.com/SamHobbsOrg/SamHobbsOrg.github.io.git and ssh://git@github.com/SimpleSamples/simplesamples.github.io.git .

(Off-topic: I have only one Github account, but I want to use SSH always. I have in my git user config
[url "ssh://git@github.com/"]
    insteadOf = https://github.com/

The git URL rewriting via url.insteadOf is done before any connection is attempted, so one can even change the protocol.)

I would use two different keys for the two accounts. The user for SSH authentication at Github is always "git". The only way I see that Github can figure out who logs in is for them to have a reverse database from SSH public keys to the user account. Which would mean that no two accounts should have the same SSH key.

Why are you using two different accounts at all?
Re: Multiple GitHub accounts [message #1850709 is a reply to message #1850682] Tue, 15 March 2022 05:16 Go to previous messageGo to next message
Sam Hobbs is currently offline Sam HobbsFriend
Messages: 12
Registered: July 2010
Junior Member
Thank you. It seems to be working. I deleted both local repositories and attempted to remove from Eclipse anything that appeared to be a potential problem. I removed the files in my .ssh. At the moment I have only attempted to clone the simplesamples repository. That however is working using the new configurations.

I did not mention that I am using Windows but I understand the differences in file and directory names. I created a new SSH key for simplesamples and stored that with GitHub. My C:\Users\sam\.ssh currently has the following files and only the following.

config
id_rsa_simplesamples
id_rsa_simplesamples.pub
known_hosts


The config file has the content provide above. I assume I will be able to also do SamHobbsOrg later.

Thank you for the detailed instructions. The important thing is that I need to (at least should) use separate SSH keys.
Re: Multiple GitHub accounts [message #1850749 is a reply to message #1850682] Tue, 15 March 2022 22:53 Go to previous messageGo to next message
Sam Hobbs is currently offline Sam HobbsFriend
Messages: 12
Registered: July 2010
Junior Member
I can now modify the two projects as easily as if they are in the same GitHub account.

I think this makes Eclipse with Egit better than Microsoft Visual Studio, at least for this. See Cannot Work With Two GitHub Accounts - Visual Studio Feedback.

I did have a few bumps. One is a problem with the .project file. That problem is probably off-topic from here and I have not researched it yet. I do not have an ignore file and I assume the .project file should be ignored. If so then I will figure it out.

[Updated on: Tue, 15 March 2022 22:54]

Report message to a moderator

Re: Multiple GitHub accounts [message #1850754 is a reply to message #1850749] Wed, 16 March 2022 07:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 32506
Registered: July 2009
Senior Member
Generally/typically the .project file should not be ignored, because it contains important information (project natures and builders) that is not redundantly represented. Some technologies/frameworks may try to synthesize it (and perhaps the .classpath file) as needed, but I'd personally not rely on that...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Multiple GitHub accounts [message #1850779 is a reply to message #1850754] Wed, 16 March 2022 19:32 Go to previous messageGo to next message
Sam Hobbs is currently offline Sam HobbsFriend
Messages: 12
Registered: July 2010
Junior Member
Ed Merks wrote on Wed, 16 March 2022 03:02
Generally/typically the .project file should not be ignored

I hope I am using the correct terminology.

When I cloned the repository to my local system it complained that there was already a .project file. At first I thought it was complaining about the entire (local) directory and I did a few things about that but when I was sure the directory did not exist it still complained. So then I deleted the .project file from the remote repository and then the clone worked. The .project file (the entire directory) did not exist locally prior to cloning.
Re: Multiple GitHub accounts [message #1850871 is a reply to message #1850682] Sun, 20 March 2022 06:14 Go to previous message
Sam Hobbs is currently offline Sam HobbsFriend
Messages: 12
Registered: July 2010
Junior Member
I am not sure how relevant this is but I think it is a solution that might help others in the future.

I am having problems getting Jekyll and GitHub Pages to work so I have been deleting the local and remote repositories and proceeding from scratch. That part is not relevant here, but see Creating a GitHub Pages site with Jekyll - GitHub Docs. In Step 16 of Creating your site I used
ssh://git@github.com/USER/REPOSITORY.git

Instead of:
https://github.com/USER/REPOSITORY.git


However in Git Bash I had to add the SSH key as in Make sure you have a key that is being used in in Error: Permission denied (publickey) - GitHub Docs.

If any of that is incorrect then I hope an expert corrects it.
Previous Topic:Unable to connect to TFS Server
Next Topic:Cannot launch after update - could not find extension
Goto Forum:
  


Current Time: Thu Oct 06 05:08:07 GMT 2022

Powered by FUDForum. Page generated in 0.11107 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top