Skip to content

Instantly share code, notes, and snippets.

@aktau
Last active July 14, 2020 03:45
Show Gist options
  • Save aktau/6121784 to your computer and use it in GitHub Desktop.
Save aktau/6121784 to your computer and use it in GitHub Desktop.
Short description of how to run an sshd under cygwin that can run gui programs, even under windows 7

The key point is that we're not going to run sshd as a service via cygrunsrv or anything, but that we're going to start it directly as the desktop user.

  1. install cygwin (the x86 version currently has more packages, such as zsh. oh-my-zsh works by the way)
  2. install ssh and if you like some helper programs (git, mc, wget, curl, nano, vim, rsync, zsh, ...)
  3. start cygwin, I don't believe it is necessary to run as administrator with my method, but I guess it can't hurt
  4. execute the same script as a normal sshd setup:
$ ssh-host-config
  1. this will generate a default /etc/sshd_config. Do NOT continue with the script, just abort (ctrl-c)
  2. edit /etc/sshd_config, look for privilege separation and set the value from "sandbox" to "no" (without the quotes)
  3. run the sshd as
$ /usr/sbin/sshd
  1. open another cygwin terminal and try to login and run notepad:
$ ssh localhost
$ notepad
  1. profit!
  2. going further, you can create a .vbs file in your startup folder that looks a bit like this:
Set WshShell = CreateObject("WScript.Shell")
cmds=WshShell.RUN("cmd /C cd C:\cygwin\bin & bash --login -c '/usr/sbin/sshd'", 0, True)
Set WshShell = Nothing
@robertvazan
Copy link

This guide no longer works as is, because latest sshd deprecates UsePrivilegeSeparation and therefore makes privilege separation mandatory.

@badrelmers
Copy link

@robertvazan I m using that in the new openssh v8.3 of cygwin with UsePrivilegeSeparation activated by default and all works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment