Cygwin(openssh/.gitconfig)+Git+Eclipse+Windows+PasswordLess SSH [message #1840629] |
Wed, 21 April 2021 04:32 |
Ari Mising name Messages: 3 Registered: December 2011 |
Junior Member |
|
|
Hello all, I been reading a bunch of tutorials and a bit lost on how to setup Eclipse with passwordless ssh.
I been using Eclipse for a while but have a more specific config that Im curious how to sort out.
I have Git for Windows installed and I'd like to be able to use PublicKey auth with my git's SSH url. It works fine on the cygwin command-line, (so my .ssh/config and .gitconfig are in my Cygwin HOME directory).
But in eclipse Im having trouble hooking it up to my ssh keys.
Some various details (maybe too much details :), sorry for the long post but thought maybe someone would read and understand what Im trying to do):
############################################
I have Cygwin and 'Git for Windows' installed so on the command line when using git it uses that (I didn't install cygwin's git).
I have openssh also installed in cygwin.
############################################
#my $cygwin_HOME/.ssh/config looks like this, different ssh-keys for the 3 different hosts:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa-github-personal
#this company wanted me to use a separate github account to connect with them, so I also use a separate key uploaded under that user different than the personal github.com account above.
Host github-company1
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa-github-company1
Host bitbucket-company2
HostName bitbucket.com
User git
IdentityFile ~/.ssh/id_rsa-bitbucket-company2
############################################
# my $cygwin_HOME/.gitconfig...
#Less important but here is my .gitconfig (just sets overrides for user/email for each github/bitbucket i have to log into based on what folder I am in):
#default name/email
[user]
name = My NickName
email = personal@gmail.com
#overrides name/email for different companies working for
[includeIf "gitdir:github-company1"]
path = ~/.gitconfig-github-company1
[includeIf "gitdir:bitbucket-company2"]
path = ~/.gitconfig-bitbucket-company2
############################################
On all 3 repo's, whether the 2 on github, and other one on bitbucket, my ssh key is added to the account (like i mean i logged into the appropriate website's like github.com and ourbitbucket.com and added my ssh key via the UI).
############################################
Note: I also have putty's pagaent running which i add a .ppk version of my above keys (i forget the reason for pageant honestly, or where its needed but I have it there just in case).
I also setup in cygwin ssh-agent like below.
I forget the reason why it is needed for some things (i remember it helped in the past store my keys so i didnt need to keep entering password maybe?):
eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME")
############################################
When I do git clones, i use these on the cygwin command line and it will work:
git clone ssh://git@github.com/personal_project/project.git
//or swap out github.com host to the other ones so my .ssh/config can pull the appropriate key
git clone ssh://git@github-company1/project/project.git
git clone ssh://git@bitbucket-company2/project/project.git
############################################
Note: this all works fine on the command line. whether i clone/push/pull from either of the above 3 gits
############################################
In Eclipse, Im not sure how to get this password-less setup that works so well in cygwin working outside of there... Here are some things I did:
*I made my HOME env var point to my cygwin home so that eclipse can pull in my .gitconfig
*I point Eclipse's Preferences->General->Network Connections->SSH2 to my cygwin .ssh folder
(C:\dev\cygwin\home\my_username\.ssh) and add my private keys in the General tab (the regular ones cygwin generates are added here, not the .ppk ones meant for pageant, [which is also running always with my .ppk keys in there as well]).
That didnt seem to help. I tried pasting the ssh:// git url of the project into Eclipse 'Git Repositories' view
to see if I can connect to it inside of Eclipse.... and just get a 'An error occurred when trying to contact ssh://git@...' msg. and on the next screen says "ssh://...: The server's host key is not cached in the registry. You have no guarantee that the server is the computer you...". Now i see the url its tries to connect to in the knownhosts file and also in the Known Hosts area of Eclipse's Preferences->SSH->Known Hosts tab. So not sure why its giving an error about the registry cache.
Some random stuff I wasn't sure if it would help that I then tried:
I installed putty's plink.exe (PS I already have pageant.exe running with my .ppk keys) and then setup GIT_SSH env var to point to the location where plink is installed like C:/putty/plink.exe (but that then breaks cygwin's git clone/push/pull and doesn't work in Eclipse as well). Not even sure if plink is needed (or another tool like tortoisegit is needed).
I was hoping Eclipse and EGIT(or JGIT, forget what is used nowadays) can just point to the .ssh/config and .gitconfig files and figure out the passwordless git.
Using the latest version of Eclipse I got last week:
Version: 2021-03 (4.19.0);
Build id: 20210312-0638
Note: if I paste the https:// git links inside of Eclipse with my actual user and pass, Eclipse works and clones the project... but I would like passwordless login over ssh:// to work if possible the same way it works on command line :).
Phew, sorry for the long post, I do like to give all details... I doubt anyone has read all this :).
But thank you if anyone has and wants me to try anything to get this to work,
Thanks!,
Ari
[Updated on: Wed, 21 April 2021 04:37] Report message to a moderator
|
|
|
|
|
|
Re: Cygwin(openssh/.gitconfig)+Git+Eclipse+Windows+PasswordLess SSH [message #1840650 is a reply to message #1840638] |
Wed, 21 April 2021 11:02 |
Thomas Wolf Messages: 576 Registered: August 2016 |
Senior Member |
|
|
As far as I can test this on OS X it appears to work. I moved my .gitconfig and .ssh directory to some other place, and started Eclipse with -Duser.home=<other place>, and set the SSH dir in the Eclipse preferences to <other place>/.ssh. Fetching via EGit works, so it does pick up the SSH and git configs, including the known_hosts file. (On OS X, setting HOME has no effect; JGit uses the Java system property user.home on OS X or Linux, which still was my real home directory, so to mimic this I had to explicitly set that Java system property.)
On Windows, HOME should be used whether you have cygwin or no. Same test in a Windows 10 VM: move .gitconfig and .ssh directory to some other place, set HOME=<other place>, start Eclipse, set the SSH dir to <other place>\.ssh. Fetching via EGit works, so it _does_ use HOME. Java system property user.home is still my real home directory, but EGit uses the value from the HOME environment variable and correctly picks up the git and SSH configs, including the known_hosts file.
I don't have any installation of Windows/Cygwin, so I cannot test with that setup.
|
|
|
|
Powered by
FUDForum. Page generated in 0.08710 seconds