Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash ssh "hostname contains invalid characters" #5261

Open
1 task done
user9436 opened this issue Nov 15, 2024 · 2 comments
Open
1 task done

Bash ssh "hostname contains invalid characters" #5261

user9436 opened this issue Nov 15, 2024 · 2 comments

Comments

@user9436
Copy link

user9436 commented Nov 15, 2024

  • I was not able to find an open or closed issue matching what I'm seeing

I'm having problems using Git Bash git over ssh with a domain\user username.

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?

64

$ git --version --build-options

git version 2.47.0.windows.2
cpu: x86_64
built from commit: 1f8a83cba6e88fad4b881885e64cfb89458e3653
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.10.1
OpenSSL: OpenSSL 3.2.3 3 Sep 2024
zlib: 1.3.1
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.22631.4317]
(c) Microsoft Corporation. All rights reserved.
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: CRLFAlways
Bash Terminal Option: ConHost
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable FSMonitor: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Bash

git clone domain\\user@gitserver:/srv/git/Repo.git
  • What did you expect to occur after running these commands?

Repo cloned.

  • What actually happened instead?
Cloning into 'Repo'...
hostname contains invalid characters
fatal: Could not read from remote repository.

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

This works in CMD and PowerShell.

This results in same error:
git clone 'domain\user@gitserver:/srv/git/Repo.git'

This results in invalid domain\username:
git clone domain\user@gitserver:/srv/git/Repo.git

Like

$ ssh -i ~/.ssh/ssh_key domain\user@gitserver
(domainuser@gitserver) Password:

No backslash in domainuser.

This works:

$ ssh -i ~/.ssh/ssh_key domain\\user@gitserver

' ' or \\ should work with clone.

If I on cloned repo do

$ git remote set-url origin 'domain\user@gitserver:/srv/git/Repo.git'

the /srv part expands to C:\Program Files\Git\srv:

$ git remote -v
origin  domain\user@gitserver;C:\Program Files\Git\srv\git\Repo.git (fetch)
origin  domain\user@gitserver;C:\Program Files\Git\srv\git\Repo.git (push)

Both with ' ' and \\

Which results in:

$ git pull
hostname contains invalid characters
fatal: Could not read from remote repository.

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

Maybe the same happens with clone.

@Vital100500
Copy link

try to update Git

Invoke-WebRequest -Uri "https://github.com/git-for-windows/git/releases/download/v2.47.0.windows.2/Git-2.47.0.2-64-bit.exe" -OutFile "$(SYSTEM.DEFAULTWORKINGDIRECTORY)/git-for-windows.exe"
Start-Process -Filepath "$(SYSTEM.DEFAULTWORKINGDIRECTORY)/git-for-windows.exe" -ArgumentList @("/VERYSILENT","/NORESTART","/NOCANCEL","/SP-","/CLOSEAPPLICATIONS","/RESTARTAPPLICATIONS","/o:PathOption=CmdTools","/o:BashTerminalOption=ConHost","/o:EnableSymlinks=Enabled","/COMPONENTS=gitlfs") -NoNewWindow -Wait

@user9436
Copy link
Author

I already have 2.47.0.windows.2, see above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants