Problem with Windows OpenSSH (MSYS2 etc)

Duane Ellis duane at duaneellis.com
Sat Jan 12 12:19:41 AEDT 2019


This is a bug/problem that shows up in several places for Windows MSYS and other variants of SSH including OpenSSH, and for example libopenssh.

What I am not sure about is where to report it so that it gets fixed.

Problem description:

A user can have two different HOME directories depending upon the state of their machine.

In general, the windows PORTS of OpenSSH do not seem to honor the HOME variable setting.

Condition #1 - is a standalone machine not connected to a network, more specifically a corporate network.

In this case, the users home directory is generally:   c:\users\<USERNAME>

For example you might open a "git-bash" shell window and type "ssh-keygen", or try to connect via SSH to some remote machine

Here your  ".ssh" directory is:  c:\users\YOURNAME\.ssh

Probably where it should be located (always)

Condition #2 - is the user has joined some Domain network and has logged in.

For example you are at work, and your laptop auto connects to the corporate network.
This can also happen if you connect via a VPN to corp network.

At this point, your home directory maps to some network drive controlled by the IT-Gods of your pay check provider, in my case it becomes the "J"  my .ssh directory becomes: "j:\.ssh"

That's not good - keeping my ssh keys on a corporate network ? I'd rather them be on my local machine
if I update one I have remember to update (sync) the other

ATTEMPTED WORK AROUND

I set the HOME variable, and in the case of git-bash-ssh - it does not honor the HOME variable for windows (it does on Linux but not windows)

The windows call that is often made is:

     https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetfolderpatha
using the value: CSIDL_PROFILE

Here in OpenSSH - the call starts here:

https://github.com/openssh/openssh-portable/blob/master/ssh.c#L624

In  libssh -  I've reported it there but it seems that is just one of many places that need this fix

https://github.com/git-for-windows/git/issues/2016

======================

So the question comes down to:

Option 1
 Fix this in the get password entry code?  Let the ENV variable override home?
 I think this is wrong because the OVERRIDE is being done by the user.
 This function is getting the pw entry from the simulated /etc/passwd

 Option 2
  Manually look for the HOME variable and use it as an override.
 
Right now, what exists is clearly wrong.

Thanks.




More information about the openssh-unix-dev mailing list