1

I am having difficulties to use git command from a bare repo located on an Ubuntu server to another bare repo located on a Windows server 2016 (within a Active Directory)

I am using https://github.com/PowerShell/Win32-OpenSSH on the windows server to allow ssh connections in.

my .ssh/config

Host INTRANET
Hostname 192.168.1.153 
User git@INTRANET  
IdentityFile ~/.ssh/id_rsa

Allow me to log in whith my rsa key

$ ssh INTRANET

Open a console where:

$ whoami
INTRANET+git

And

$ pwd
/c/Users/git

then

$ ls
 myrepo.git

And finally:

$ ls -all myrepo.git/
total 25
drwxr-xr-x 1 INTRANET+git 197121   0 Mar 27 13:24 .
drwxr-xr-x 1 INTRANET+git 197121   0 Mar 27 15:52 ..
-rw-r--r-- 1 INTRANET+git 197121  60 Mar 23 11:46 FETCH_HEAD
-rw-r--r-- 1 INTRANET+git 197121  23 Mar 16 11:31 HEAD
-rw-r--r-- 1 INTRANET+git 197121 151 Mar 16 11:30 config
-rw-r--r-- 1 INTRANET+git 197121  73 Mar 16 11:30 description
drwxr-xr-x 1 INTRANET+git 197121   0 Mar 27 13:24 hooks
drwxr-xr-x 1 INTRANET+git 197121   0 Mar 27 13:24 info
drwxr-xr-x 1 INTRANET+git 197121   0 Mar 27 13:24 objects
-rw-r--r-- 1 INTRANET+git 197121 284 Mar 16 11:31 packed-refs
drwxr-xr-x 1 INTRANET+git 197121   0 Mar 27 13:24 refs

Ubuntu is holding a bare repo where

$ cat config
[remote "origin"]
    url = INTRANET:~/myrepo.git

But when I

$ git --bare fetch
fatal: ''~/myrepo.git'' does not appear to be a git repository
fatal: Could not read from remote repository.

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

1 Answers1

0

Try instead using the full path

url = INTRANET:/c/Users/git/myrepo.git

That way, ~ does not have to be interpreted.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • You mean INTRANET:/c/Users/git/myrepo.git? – Peter Peterson Mar 28 '18 at 05:09
  • I still receive the same `fatal: ''/c/Users/git/myrepo.git'' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.` – Peter Peterson Mar 28 '18 at 07:03
  • @PeterPeterson When you do a `ssh INTRANET`, can you go and `cd /c/Users/git/myrepo.git`, and do a `git status` in it, just to confirm the repo exists? – VonC Mar 28 '18 at 07:07
  • `ssh INTRANET` then `cd /c/Users/git/myrepo.git`. Since it's a bare repo a `git branch` give me `*master` – Peter Peterson Mar 28 '18 at 07:16
  • @PeterPeterson Can you change the User fro git@INTRANET to git in your ssh config? – VonC Mar 28 '18 at 07:30
  • I did try with no changes. `ssh git@192.168.1.xxx` is letting me in. But `git --bare fetch ssh://git@192.168.1.xxx/c/Users/git/myrepo.git master` still give me `fatal: ''/c/Users/git/myrepo.git'' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists` – Peter Peterson Mar 28 '18 at 08:32
  • @PeterPeterson I suppose `git ls-remote ssh://git@192.168.1.xxx/c/Users/git/myrepo.git` does not work either? – VonC Mar 28 '18 at 08:35
  • sameish. frustration here. – Peter Peterson Mar 28 '18 at 08:42
  • @PeterPeterson Check your `env|grep -i ssh` in case anything could influence an SSH connection. – VonC Mar 28 '18 at 08:46
  • server side (win2016) `$ env|grep -i ssh` `SSH_CONNECTION=192.168.1.21 59606 192.168.1.153 22 SSH_CLIENT=192.168.1.21 59606 22 PLINK_PROTOCOL=ssh PATH=/mingw64/bin:/usr/bin:/c/Users/git/bin:/usr/bin:/c/Windows/system32:/c/Windows:/ c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/wamp/bin/php/ph p5.5.12:/c/wamp/bin/php/php5.5.12/ext:/c/Program Files/Firebird/Firebird_2_5:/c/Progr am Files/OpenSSH/bin:/cmd:/usr/bin:/mingw64/bin:/c/Windows/system32/config/systemprof ile/AppData/Local/Microsoft/WindowsApps:/c/Users/git/AppData/Local/Microsoft/WindowsA pps ` – Peter Peterson Mar 28 '18 at 08:50
  • client side (ubuntu) `$ env|grep -i ssh` `SSH_AGENT_PID=5270 SSH_CLIENT=192.168.1.33 53166 22 SSH_TTY=/dev/pts/0 SSH_AUTH_SOCK=/tmp/ssh-xz7DMENLb9jD/agent.5269 SSH_CONNECTION=192.168.1.33 53166 192.168.1.21 22` – Peter Peterson Mar 28 '18 at 08:52
  • @PeterPeterson Can you set `GIT_SSH_COMMAND` (introduced here: https://stackoverflow.com/a/38474220/6309) to `ssh -v` in order to see what is going on? – VonC Mar 28 '18 at 11:20
  • GIT_SSH_COMMAND is not set, `echo $GIT_EXEC_PATH/ C:\Program Files\Git\mingw64/libexec/git-core/` – Peter Peterson Mar 28 '18 at 12:20
  • I meant, on Ubuntu: `GIT_SSH_COMMAND='ssh -v' git ls-remote INTRANET:/c/Users/git/myrepo.git` – VonC Mar 28 '18 at 12:21
  • `debug1: Sending environment. debug1: Sending command: git-upload-pack '/c/Users/git/myrepo.git' fatal: ''/c/Users/git/myrepo.git'' does not appear to be a git repository debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK Transferred: sent 2712, received 2972 bytes, in 0.2 seconds Bytes per second: sent 15241.3, received 16702.4 debug1: Exit status 128 fatal: Could not read from remote repository.` – Peter Peterson Mar 28 '18 at 12:28
  • @PeterPeterson Strange the path should be correct (as in https://stackoverflow.com/a/39593539/6309). What happens if you open a bash session on Windows, and type `git ls-remote /c/Users/git/myrepo.git` (assuming that `dir c:\Users\git\myrepo.git` does work) – VonC Mar 28 '18 at 12:31
  • everything seems OK `$ git ls-remote /c/Users/git/myrepo.git/ 2bd71e2bf025d992ec3ceba1bfd398fa69b1a0e7 HEAD 2bd71e2bf025d992ec3ceba1bfd398fa69b1a0e7 refs/heads/master` – Peter Peterson Mar 28 '18 at 12:37
  • @PeterPeterson Mmm... that looks like https://github.com/PowerShell/Win32-OpenSSH/issues/400 – VonC Mar 28 '18 at 13:04
  • RIGHT; "Looks like if I do not mention any protocol, git is picking up ssh and cloning works fine" – Peter Peterson Mar 30 '18 at 14:47
  • @PeterPeterson the scp-like syntax is indeed an SSH one (xxx:yyy) – VonC Mar 30 '18 at 15:18