git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.39k stars 2.54k forks source link

Wrong HOME path used with all default install options. #2059

Closed Anakin-Hao closed 3 years ago

Anakin-Hao commented 5 years ago

Setup

git version 2.20.1.windows.1
cpu: x86_64
built from commit: 7c9fbc07db0e2939b36095df45864b8cda19b64f
sizeof-long: 4
sizeof-size_t: 8
This is a fresh git install on a brand new win 10.
Microsoft Windows [Version 10.0.17763.55]
Editor Option: VIM
Custom Editor Path: 
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled

NONE

Details

PowerShell

git clone git:****************

using correct home folder and carry with git clone

Cloning into 'myproject'...
Could not create directory '/home/haoa/.ssh'
The authenticity of host 'github.com (192.30.255.112)' can't be established.
RSA key fingerprint is SHA256:***************************************************.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/haoa/.ssh/known_hosts).
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

N/A

dscho commented 5 years ago

What are the values of $env:USERPROFILE, $env:HOMEDRIVE, $env:HOMEPATH and $env:HOME in your regular PowerShell?

Anakin-Hao commented 5 years ago
$env:USERPROFILE
C:\Users\haoa

$env:HOMEDRIVE
H:

$env:HOMEPATH
\

$env:HOME
C:\Users\haoa
dscho commented 5 years ago

And if you open a Git Bash, what does pwd say?

Also, did you edit C:\Program Files\Git\etc\nsswitch.conf or a passwd in the same directory?

Anakin-Hao commented 5 years ago

No longer reproducible due to a new pc build at work.

mseele commented 4 years ago

@dscho Can you please re-open that issue, i get the same error inside vscode/cmd/powershell:

PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> git push
ECDSA key fingerprint is SHA256:6NYrSy8LS0RjSFHOUrTbyuF/ycc/dv8xhCm9IgXP0qM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Failed to add the host to the list of known hosts (/home/mseele/.ssh/known_hosts).
mseele@ghlx06.guh-local.de's password: 
Everything up-to-date

Setup

PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> git --version --build-options
git version 2.25.0.windows.1
cpu: x86_64
built from commit: 7c71c859c97853ed057da5cbab12f3c13b5554df
sizeof-long: 4
sizeof-size_t: 8
PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> cmd.exe /c ver

Microsoft Windows [Version 10.0.18363.657]
PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> type "C:\Program Files\Git\etc\install-options.txt"
Editor Option: VIM
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled

Clean,new installation with chocolaty via choco install git

Details

I can reproduce it inside vscode, under cmd and PowerShell 6.2.4

PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> git push
ECDSA key fingerprint is SHA256:6NYrSy8LS0RjSFHOUrTbyuF/ycc/dv8xhCm9IgXP0qM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Failed to add the host to the list of known hosts (/home/mseele/.ssh/known_hosts).
mseele@ghlx06.guh-local.de's password: 
Everything up-to-date

Home dir should be C:\Users\mseele

For the environment variables i go these results:

PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> $env:USERPROFILE
C:\Users\mseele
PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> $env:HOMEDRIVE
C:
PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> $env:HOMEPATH
\Users\mseele
PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> $env:HOME
C:\Users\mseele

Git expected home dir to be /home/mseele which is wrong.

Occurs with all repos

dscho commented 4 years ago

Can you paste the output of where git?

dscho commented 4 years ago

(BTW this is technically a new ticket... but let's continue the conversation here.)

mseele commented 4 years ago

where git generates no output:

PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> where git

i don't want to create a new ticket because of the

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

checkbox at the beginning of a new ticket. If you mind, i can open a new one!?

mseele commented 4 years ago

i need to correct myself:

where git generates no output under powershell. under cmd i see this output:

C:\Users\mseele>where git
C:\Program Files\Git\cmd\git.exe
dscho commented 4 years ago

If you mind, i can open a new one!?

No, please don't worry about that.

where git generates no output under powershell. under cmd i see this output:

C:\Users\mseele>where git
C:\Program Files\Git\cmd\git.exe

That is the expected output. However, maybe you have a HOME environment variable set already? Like, what does your PowerShell say when you ask echo $env:HOME? Or for that matter, HOMEDRIVE, HOMEPATH and USERPROFILE?

rimrul commented 4 years ago

They already included the values of all those variables in their first comment under "what did you expect..."

mseele commented 4 years ago

powershell:

PS C:\Users\mseele> echo $env:USERPROFILE
C:\Users\mseele
PS C:\Users\mseele> echo $env:HOMEDRIVE
C:
PS C:\Users\mseele> echo $env:HOMEPATH
\Users\mseele
PS C:\Users\mseele> echo $env:HOME
c:\Users\mseele

cmd:

C:\Users\mseele>echo $env:USERPROFILE
$env:USERPROFILE

C:\Users\mseele>echo $env:HOMEDRIVE
$env:HOMEDRIVE

C:\Users\mseele>echo $env:HOMEPATH
$env:HOMEPATH

C:\Users\mseele>echo $env:HOME
$env:HOME
dscho commented 4 years ago

They already included the values of all those variables in their first comment under "what did you expect..."

Whoops, I was on my phone and could not find it... Sorry.

powershell:

PS C:\Users\mseele> echo $env:USERPROFILE
C:\Users\mseele
PS C:\Users\mseele> echo $env:HOMEDRIVE
C:
PS C:\Users\mseele> echo $env:HOMEPATH
\Users\mseele
PS C:\Users\mseele> echo $env:HOME
c:\Users\mseele

That looks correct to me.

So that leaves pretty much only one option: that the /etc/nsswitch.conf became incorrect somehow. Can you check that the line talking about db_home lists env first? This is how it should look like:

db_home: env windows cygwin desc
mseele commented 4 years ago

this is my /etc/nsswitch.conf under c:\Program Files\Git\etc\nsswitch.conf:

# Begin /etc/nsswitch.conf

passwd: files db
group: files # db

db_enum: cache builtin

db_home: env windows cygwin desc
db_shell: env windows # cygwin desc
db_gecos: env # cygwin desc

# End /etc/nsswitch.conf
dscho commented 4 years ago

@mseele hrmpf. This looks correct, so it looks very weird to me that your OpenSSH decides to use /home/mseele.

It's just one more weird thing on this already weird day.

When I try to run an integrated terminal in my copy of VS Code, I fail to see the behavior you see. When I call git -c alias.s="!ssh-keygen" s, it shows me a path in my actual home directory (as opposed to /home/<my-username>).

Do you maybe have an MSYS2 or Cygwin on your PATH? Although that should not matter: Git for Windows should prepend its own MSYS2's /usr/bin. So this is disconcerting. Can you ensure (e.g. via the Task Manager, by clicking on the properties of the running process) that the ssh process you see is actually started from C:\Program Files\Git\usr\bin\ssh.exe?

mseele commented 4 years ago

When I try to run an integrated terminal in my copy of VS Code, I fail to see the behavior you see. When I call git -c alias.s="!ssh-keygen" s, it shows me a path in my actual home directory (as opposed to /home/<my-username>).

for me the same:

PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> git -c alias.s="!ssh-keygen" s
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mseele/.ssh/id_rsa): 

Do you maybe have an MSYS2 or Cygwin on your PATH? Although that should not matter: Git for Windows should prepend its own MSYS2's /usr/bin. So this is disconcerting. Can you ensure (e.g. via the Task Manager, by clicking on the properties of the running process) that the ssh process you see is actually started from C:\Program Files\Git\usr\bin\ssh.exe?

No, there is not MSYS2 or Cygwin on the path. when i run git push, process_explorer generates tree processes in this order:

dscho commented 4 years ago

When I try to run an integrated terminal in my copy of VS Code, I fail to see the behavior you see. When I call git -c alias.s="!ssh-keygen" s, it shows me a path in my actual home directory (as opposed to /home/<my-username>).

for me the same:

PS C:\dev\workspaces\eDMRTaskBasedView\git\eDMRTaskBasedView\ManageOneProductDataModelClient> git -c alias.s="!ssh-keygen" s
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mseele/.ssh/id_rsa): 

Okay, next thing: git -c alias.s="!env | grep HOME" s

mseele commented 4 years ago

cmd:

C:\Users\mseele>git -c alias.s="!env | grep HOME" s
JAVA_HOME=C:\dev\java\jdk-11_openj9
HOME=/c/Users/mseele
GIT_CONFIG_PARAMETERS='alias.s='\!'env | grep HOME'
HOMEDRIVE=C:
HOMEPATH=\Users\mseele

powershell:

PS C:\Users\mseele> git -c alias.s="!env | grep HOME" s
JAVA_HOME=C:\dev\java\jdk-11_openj9
HOME=/c/Users/mseele
GIT_CONFIG_PARAMETERS='alias.s='\!'env | grep HOME'
HOMEDRIVE=C:
HOMEPATH=\Users\mseele
dscho commented 4 years ago

Next stab in the dark: git -c alias.s="!which ssh-keygen" s

mseele commented 4 years ago

cmd:

C:\Users\mseele>git -c alias.s="!which ssh-keygen" s
/usr/bin/ssh-keygen

powershell:

PS C:\Users\mseele> git -c alias.s="!which ssh-keygen" s
/usr/bin/ssh-keygen
dscho commented 4 years ago

That is most strange. Maybe you can log verbosely by passing a couple -v flags, and maybe that will tell us where this home directory is configured?

mseele commented 4 years ago

which commands can i run with -v? We can also do a screensharing session if that helps!?

dscho commented 4 years ago

ssh -v -v -v ... should log verbosely. (sorry, I'm still struggling with the v2.25.1 release, and won't have time for screensharing today)

mseele commented 4 years ago

running .\ssh.exe -v -v -v ghlx06.guh-local.de from C:\Program Files\Git\usr\bin gives me that

PS C:\Program Files\Git\usr\bin> .\ssh.exe -v -v -v ghlx06.guh-local.de
OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "ghlx06.guh-local.de" port 22
debug2: ssh_connect_direct
debug1: Connecting to ghlx06.guh-local.de [192.168.100.87] port 22.
debug1: Connection established.
Could not create directory '/home/mseele/.ssh'.
debug1: identity file /home/mseele/.ssh/id_rsa type -1
debug1: identity file /home/mseele/.ssh/id_rsa-cert type -1
debug1: identity file /home/mseele/.ssh/id_dsa type -1
debug1: identity file /home/mseele/.ssh/id_dsa-cert type -1
debug1: identity file /home/mseele/.ssh/id_ecdsa type -1
debug1: identity file /home/mseele/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/mseele/.ssh/id_ed25519 type -1
debug1: identity file /home/mseele/.ssh/id_ed25519-cert type -1
debug1: identity file /home/mseele/.ssh/id_xmss type -1
debug1: identity file /home/mseele/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to ghlx06.guh-local.de:22 as 'mseele'
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa   
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:6NYrSy8LS0RjSFHOUrTbyuF/ycc/dv8xhCm9IgXP0qM
The authenticity of host 'ghlx06.guh-local.de (192.168.100.87)' can't be established.
ECDSA key fingerprint is SHA256:6NYrSy8LS0RjSFHOUrTbyuF/ycc/dv8xhCm9IgXP0qM.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

maybe important: when i run ssh from somewhere else, i get:

PS C:\Users\mseele> ssh -v -v -v ghlx06.guh-local.de
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug3: Failed to open file:C:/Users/mseele/.ssh/config error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolving "ghlx06.guh-local.de" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to ghlx06.guh-local.de [192.168.100.87] port 22.
debug1: Connection established.
debug3: Failed to open file:C:/Users/mseele/.ssh/id_rsa error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_rsa.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_rsa type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_rsa-cert error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_rsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_rsa-cert type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_dsa error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_dsa.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_dsa type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_dsa-cert error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_dsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_dsa-cert type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_ecdsa error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_ecdsa.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_ecdsa type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_ecdsa-cert error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_ecdsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_ecdsa-cert type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_ed25519 error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_ed25519.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_ed25519 type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_ed25519-cert error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_ed25519-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_ed25519-cert type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_xmss error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_xmss.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_xmss type -1
debug3: Failed to open file:C:/Users/mseele/.ssh/id_xmss-cert error:2
debug3: Failed to open file:C:/Users/mseele/.ssh/id_xmss-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\mseele/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to ghlx06.guh-local.de:22 as 'guh\\mseele'
debug3: hostkeys_foreach: reading file "C:\\Users\\mseele/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\mseele/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from ghlx06.guh-local.de
debug3: Failed to open file:C:/Users/mseele/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:6NYrSy8LS0RjSFHOUrTbyuF/ycc/dv8xhCm9IgXP0qM
debug3: hostkeys_foreach: reading file "C:\\Users\\mseele/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\mseele/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from ghlx06.guh-local.de
debug3: Failed to open file:C:/Users/mseele/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug3: hostkeys_foreach: reading file "C:\\Users\\mseele/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\mseele/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from 192.168.100.87
debug3: Failed to open file:C:/Users/mseele/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug1: Host 'ghlx06.guh-local.de' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\mseele/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug3: unable to connect to pipe \\\\.\\pipe\\openssh-ssh-agent, error: 2
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug2: key: C:\\Users\\mseele/.ssh/id_rsa (0000000000000000)
debug2: key: C:\\Users\\mseele/.ssh/id_dsa (0000000000000000)
debug2: key: C:\\Users\\mseele/.ssh/id_ecdsa (0000000000000000)
debug2: key: C:\\Users\\mseele/.ssh/id_ed25519 (0000000000000000)
debug2: key: C:\\Users\\mseele/.ssh/id_xmss (0000000000000000)
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: C:\\Users\\mseele/.ssh/id_rsa
debug3: no such identity: C:\\Users\\mseele/.ssh/id_rsa: No such file or directory
debug1: Trying private key: C:\\Users\\mseele/.ssh/id_dsa
debug3: no such identity: C:\\Users\\mseele/.ssh/id_dsa: No such file or directory
debug1: Trying private key: C:\\Users\\mseele/.ssh/id_ecdsa
debug3: no such identity: C:\\Users\\mseele/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: C:\\Users\\mseele/.ssh/id_ed25519
debug3: no such identity: C:\\Users\\mseele/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: C:\\Users\\mseele/.ssh/id_xmss
debug3: no such identity: C:\\Users\\mseele/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
debug3: failed to open file:C:/dev/tty error:2
debug1: read_passphrase: can't open /dev/tty: No such file or directory
guh\mseele@ghlx06.guh-local.de's password:

no problem and no rush for that, i just thought that would help to solve that strange problem...

dscho commented 4 years ago

running .\ssh.exe -v -v -v ghlx06.guh-local.de from C:\Program Files\Git\usr\bin gives me that

PS C:\Program Files\Git\usr\bin> .\ssh.exe -v -v -v ghlx06.guh-local.de
OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "ghlx06.guh-local.de" port 22
debug2: ssh_connect_direct
debug1: Connecting to ghlx06.guh-local.de [192.168.100.87] port 22.
debug1: Connection established.
Could not create directory '/home/mseele/.ssh'.
debug1: identity file /home/mseele/.ssh/id_rsa type -1
[...]

This part would have been enough to determine that ssh does not really read any other configuration file before trying to use /home/mseele as your home directory. At this point, I am at a loss what it could be.

maybe important: when i run ssh from somewhere else, i get:

PS C:\Users\mseele> ssh -v -v -v ghlx06.guh-local.de
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[...]

This is most likely the native Windows OpenSSH:

C:\>where ssh.exe
C:\Windows\System32\OpenSSH\ssh.exe

no problem and no rush for that, i just thought that would help to solve that strange problem...

Given that this is a rather rare problem, and given that it would take some debugging skills on the part of somebody who has a setup where the problem can be reproduced, I think this is low priority.

If you want to investigate further, I would suggest trying to analyze the output of strace -o ssh.trace ssh.exe ghlx06.guh-local.de; maybe there is some clarity to be gained from that strace.

mseele commented 4 years ago

The output of strace -o ssh.trace ssh.exe ghlx06.guh-local.de is

PS C:\Program Files\Git\usr\bin> .\strace.exe -o ssh.trace ssh.exe ghlx06.guh-local.de
Could not create directory '/home/mseele/.ssh'.
The authenticity of host 'ghlx06.guh-local.de (192.168.100.87)' can't be established.
ECDSA key fingerprint is SHA256:6NYrSy8LS0RjSFHOUrTbyuF/ycc/dv8xhCm9IgXP0qM.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Is there a way to use another ssh client instead of the included ssh client? GIT_SSH is ignored in git for windows (https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables), right? Or is there any other way to configure the home path for ssh? This is a real stopper for us :/

rimrul commented 4 years ago

Isn't that just the output of the ssh command? Looks to me like the strace output landed in a file C:\Program Files\Git\usr\bin\ssh.trace.

mseele commented 4 years ago

Isn't that just the output of the ssh command? Looks to me like the strace output landed in a file C:\Program Files\Git\usr\bin\ssh.trace.

You're right, sorry for that. I've attached the ssh.trace file:

ssh.trace

rimrul commented 4 years ago

Lines 86-88 seem interesting. Line 88 is the first occurence of /home/mseele in pwdgrp::fetch_account_from_windows and the lines before it mention a windows error 1355 in sec_auth.cc:367.

Windows error 1355 seems to be related to authentication against a domain controller.

mseele commented 4 years ago

I Know that our company has a domain controller and linux home directories for every user. But is it not possible to override this or detect that we are under windows and should use the windows home dir...not the remote linux one?

dscho commented 3 years ago

Closing this as stale.

OscarL commented 2 years ago

This is an old issue, but... For what it's worth...

I was having that same Could not create directory '/home/<USER_NAME_HERE>/.ssh' issue.

I solved it by making sure that the etc\ssh\ssh_config file on my local copy of MinGit includes a line at the end pointing where I want:

IdentityFile D:\<USER_NAME_HERE>\ssh\id_ed25519

Now I can git push from my weird cmd.exe+click+GoW+MinGit setup, if I need to, and I'm happy :-)

DouglasRoyds commented 1 year ago

FWIW, an strace excerpt from the same error on my machine attached: could-not-create-dir-ssh.txt

I am logged in to this machine via an LDAP domain. The machine has previously had cygwin installed.

I attempted a directory symlink as C:\Program Files\Git\home\roydsd\.ssh, which silenced the Could not create directory error, but then public key authentication failed, probably due to file permission errors (ssh is fussy about that).

I tried putting /c/Windows/System32/OpenSSH to the front of the PATH, to use the built-in ssh client, but this also failed:

Pseudo-terminal will not be allocated because stdin is not a terminal.
CreateProcessW failed error:193
ssh_askpass: posix_spawnp: Unknown error
Host key verification failed.

git version 2.39.2.windows.1