Why does Cygwin need _two_ reboots before sshd picks up PATH environment var changes?

Viewed 35

I have a very strange problem with Cygwin sshd and changing the PATH environment variable through the Windows control panel. This is with Windows 10 64 running in a Parallels VM

After a reboot ssh sessions into the Windows machine will still use the old path. Local Cygwin sessions have no such problem: they will use the new path.

Note the bold text: I am aware that without the reboot this is expected to happen (because sshd got started with the old environment). But the After the reboot has got me baffled. If I ssh into the machine I see the old PATH. If I then reboot the VM again and ssh in again I finally see the new path.

Incidentally (fodder for future people googling this) I had the problem while using gitlab-runner to run CI/CD jobs on Windows using Parallels VMs on my Mac. So I would prepare the VM to have all the right tools installed and everything set correctly, then shut it down. gitlab-runner will then clone the VM and run the CI/CD jobs on it. Works now, as long as I reboot the original VM twice with an ssh session in between before having it cloned by gitlab-runner:-)

2 Answers

I never posted the answer I found: the problem was that hibernate was enabled on Windows. Actually the first "restart" was usually a shutdown followed by a startup.

But, by default Win10 has hibernate enabled, and if that is the case a shutdown and startup don't actually reboot the OS.

Disabling hibernate fixed it.

Double-check your Cygwin sshd installation, as described in "Installing Cygwin and Starting the SSH Daemon"

  • it makes sure the %PATH% does not reference other SSH, like W10 OpenSSH.
  • it stops any other SSH service.
  • it defines a Cygwin SSH Windows service, using a local account, which then should pick up the same account new path after a single reboot (or even with restarting the service, without reboot)

Cygwin sshd service

I am not sure why you need two reboots in your case, but see if that Cygwin sshd setup works better.

Related