1

I installed Cygwin and TortoiseGit. And I created ssh-key by ssh-key-gen -t rsa and registered public key to my GitHub page. When in gitbash terminal, it worked, however, Cygwin terminal failed.

// Cygwin
$ git pull
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I noticed they use different git. Then, how do I specify git path in Cygwin? My OS is Windows 10.

// Cygwin
$ where git
C:\Program Files\Git\cmd\git.exe
$ which git
/cygdrive/c/Program Files/Git/cmd/git

// gitbash (MINGW64)
$ where git
C:\Program Files\Git\mingw64\bin\git.exe
C:\Program Files\Git\cmd\git.exe
$ which git
/mingw64/bin/git
Yue Lin Ho
  • 2,945
  • 26
  • 36
jef
  • 3,890
  • 10
  • 42
  • 76
  • with cygwin uses its git. it will make easier to manage the ssh-key created with cygwin ssh-key-gen – matzeri Oct 06 '17 at 06:06

1 Answers1

2

The git path itself is not that important for ssh.

What matters is the $HOME, because git (any git) would search for the public/private ssh keys in $HOME/.ssh

Double-check your echo $HOME output in both scenario, and check the result of ssh -Tv auser@aserver (replace user and server by the beginning of the ssh URL seen when typing git remote -v)

Also, Cygwin has its own Git package as I explain here.
And it needs a .bash_profile as a setting.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `$HOME` set correctly and ssh authentication was success by `ssh -Tv`. I still think this git is not set correctly. – jef Oct 08 '17 at 01:20
  • @jef can you set the environment variable `GIT_SSH_COMMAND` (`set` on `CMD`, `export` on bash) to `ssh -v`, and see in both case what happen on `git pull`? There should be a difference. – VonC Oct 08 '17 at 03:59
  • @jef And you did not mention you were using a passphrase-protected ssh private key (https://stackoverflow.com/q/46627127/6309) – VonC Oct 08 '17 at 04:11