0

I am trying to use Cygwin to clone from our company Git server. However, Cygwin uses the external Git bash, which is installed on my machine. This leads to compatibility problems. I have a key in C:\Users\user.ssh and also separate SSH keys in /home/user/.ssh in Cygwin. However, adding verbosity to ssh, I see this,

debug1: identity file /c/cygwin/home/user/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory

Now, Cygwin maps the C drive to /cygdrive/c, so this fails. Further, creating a softlink ln -s /c /cygdrive/c gives the same result. Anyone who knows how I can reconfigure either Cygwin or ssh to handle this?
BR
Patrik

EDIT:
I obviously have the same problem with all other SSH files, like keys and such.

EDIT2:
I have tried to mess around with certain variables in the ssh client used by Git. After adding and then removing the propery UserKnownHostsFile, things suddenly started to work. I have no idea how it started to work again, but the behavior is extremely odd.

patrik
  • 4,506
  • 6
  • 24
  • 48
  • Check your `/etc/passwd` See https://stackoverflow.com/a/25127368/7976758, https://stackoverflow.com/a/39551855/7976758 and https://stackoverflow.com/search?q=%5Bcygwin%5D+%5Bssh%5D+home – phd Jun 12 '20 at 13:17
  • @phd I am unsure if this can solve the problem. As I understand it, git bash does not use the Cygwin built in SSH, which leads to that changes in SSH will solve the problem for Cygwin, at the consequence of breaking for the rest of the system. – patrik Jun 12 '20 at 13:30
  • @phd I did not explain things in a good way Cygwin users the external Git bash downloaded, but this application is using some other ssh version than the ssh provided by cygwin. – patrik Jun 12 '20 at 13:39
  • Can you use Cygwin for all your tasks? Install everything from Cygwin, set `$PATH` that includes Cygwin but exclude MSYS (git-bash et al). – phd Jun 12 '20 at 13:45
  • what is the output of `cygpath -w ~` and of `echo $PATH` ? – matzeri Jun 12 '20 at 19:09

1 Answers1

1

To avoid that Cygwin uses any non Cygwin programs unless called with full path, the

/etc/profile

contains

  # setting CYGWIN_USEWINPATH non-empty in the system variables
  # assumes that you've already set up PATH so that Cygwin works
  # correctly -- no further alteration is done
  if [ ${CYGWIN_USEWINPATH-nopathprepend} ] ; then
    # setting CYGWIN_NOWINPATH non-empty in the system variables
    # prevents use of the existing PATH and a clean PATH just for
    # Cygwin is set up -- you need to add any extra path components
    # you need in your personal startup files
    if [ ${CYGWIN_NOWINPATH-addwinpath} = "addwinpath" ] ; then
        PATH="/usr/local/bin:/usr/bin${PATH:+:${PATH}}"
    else
        PATH="/usr/local/bin:/usr/bin"
    fi
  fi

so if you set the variable CYGWIN_NOWINPATH to any not null value the PATH will be sanitized and only Cygwin program will be executed.
You can try with a batch file like:

@echo off

C:
chdir C:\cygwin64\bin
set CYGWIN_NOWINPATH='true'

mintty -

and from it, assumning you have installed Cygwin git and Openssh

$ type git
git is /usr/bin/git

$ type ssh
ssh is /usr/bin/ssh
matzeri
  • 8,062
  • 2
  • 15
  • 16
  • This is a good workaround, should I use git coming with the Cygwin installation. However, this does not solve the problem (which by the way managed to solve itself for virtually no reason...). The cause of the former problem is that I do not have Git installed for Cygwin, I have installed Git separately from Cygwin. When I run ssh, it uses the right version, but the Git installation (internally) selects another version of ssh, which have nothing to do with the Cygwin config. The command "which ssh" will indeed show /usr/bin/ssh. – patrik Jun 15 '20 at 10:34