While my Linux machines can access the hosted repositories on the NAS using its hostname, my Windows machine fails to access it from command line / Visual Studio Code. During my debugging attempts I found a way so that at least TortoiseGit can access the repositories: I had to add an env var GIT_SSH_COMMAND=ssh -vvv (besides the already existing GIT_SSH=C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe).
When I issue a git pull via cmd for a repository accessed in Git config via url = ssh://gituser@my-devices-hostname/volume1/git/reponame.git I get the following output:
OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019 debug1: Reading configuration data /etc/ssh/ssh_config debug2: resolving "my-devices-hostname" port 22 debug2: ssh_connect_direct debug1: Connecting to my-devices-hostname [192.168.0.50] port 22. getaddrinfo: atch: Name or service not known ssh: connect to host my-devices-hostname port 22: failure fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. When I replace the hostname by a static IP I get the same error:
OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019 debug1: Reading configuration data /etc/ssh/ssh_config debug2: resolve_canonicalize: hostname 192.168.0.50 is address debug2: ssh_connect_direct debug1: Connecting to 192.168.0.50 [192.168.0.50] port 22. getaddrinfo: atch: Name or service not known ssh: connect to host 192.168.0.50 port 22: failure fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. When doing the same with TortoiseGit, everything works fine, I get:
OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019 debug1: Reading configuration data /etc/ssh/ssh_config debug2: resolving "my-devices-hostname" port 22 debug2: ssh_connect_direct debug1: Connecting to my-devices-hostname [192.168.0.50] port 22. debug1: Connection established. ... I've recently set up a new DSL router (Fritz!Box 7590), maybe this is somehow related. Since I guessed that the problem could be related to IPv6, I've disabled IPv6 on the Synology NAS, but no change.
Update: fedrik asked me to perform a manual ssh. Here are the results:
ssh gituser@my-devices-hostname fatal: Interactive git shell is not enabled. hint: ~/git-shell-commands should exist and have read and execute access. Connection to my-devices-hostname closed. and surprisingly:
ssh [email protected] ssh: connect to host 196.168.0.50 port 22: Connection timed out I updated my Git- and Tortoise installation, now I get
ssh [email protected] fatal: Interactive git shell is not enabled. hint: ~/git-shell-commands should exist and have read and execute access. Connection to 192.168.0.50 closed. The hostname based ssh remained the same.
Inspired by the answer from VonC, I checked if there are multiple instances of ssh installed on my system. I found the following:
C:\Windows\System32\OpenSSH\ssh.exe C:\Program Files\Git\usr\bin\ssh.exe So I checked (after updating Tortoise and Git for Windows), which one is used. First, I left GIT_SSH_COMMAND=ssh -vvv:
git pull OpenSSH_8.4p1, OpenSSL 1.1.1h 22 Sep 2020 debug1: Reading configuration data /etc/ssh/ssh_config debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/c/Users/user/.ssh/known_hosts' debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/c/Users/user/.ssh/known_hosts2' debug2: resolving "my-devices-hostname" port 22 debug2: ssh_connect_direct debug1: Connecting to my-devices-hostname [192.168.0.50] port 22. getaddrinfo: atch: Name or service not known ssh: connect to host my-devices-hostname port 22: failure fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. "C:\Program Files\Git\usr\bin\ssh.exe" -vvv [email protected] OpenSSH_8.4p1, OpenSSL 1.1.1h 22 Sep 2020 debug1: Reading configuration data /etc/ssh/ssh_config debug2: resolve_canonicalize: hostname 192.168.0.50 is address debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/c/Users/bjoer/.ssh/known_hosts' debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/c/Users/bjoer/.ssh/known_hosts2' debug2: ssh_connect_direct debug1: Connecting to 192.168.0.50 [192.168.0.50] port 22. debug1: Connection established. After I changed the env var: GIT_SSH_COMMAND=C:/Windows/System32/OpenSSH/ssh.exe -vvv I got this:
git pull OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 debug3: Failed to open file:C:/Users/user/.ssh/config error:2 debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2 debug2: resolving "my-devices-hostname" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to my-devices-hostname [192.168.0.50] port 22. getaddrinfo: atch: Der angegebene Host ist unbekannt. ssh: connect to host my-devices-hostname port 22: failure fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. C:\Windows\System32\OpenSSH\ssh.exe -vvv [email protected] OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 debug3: Failed to open file:C:/Users/user/.ssh/config error:2 debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2 debug2: resolve_canonicalize: hostname 192.168.0.50 is address debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to 192.168.0.50 [192.168.0.50] port 22. debug1: Connection established. When I unset GIT_SSH and GIT_SSH_COMMAND env vars, I get this:
git pull getaddrinfo: atch: Name or service not known ssh: connect to host my-devices-hostname port 22: failure fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. So, I can connect via SSH to the Git server, but when issues from the Git executable itself, it fails. When I launch up a WSL on the same machine, I can perform a git pull without problems.
Any suggestions on how to tackle this issue?
sshto the host?