Skip to content

Instantly share code, notes, and snippets.

@cuibonobo
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save cuibonobo/dccefadf0435ebae1435 to your computer and use it in GitHub Desktop.

Select an option

Save cuibonobo/dccefadf0435ebae1435 to your computer and use it in GitHub Desktop.
Getting an SSH server up on a Windows machine
  • Run the CygWin installer and make sure that openssh is installed from the 'Net' category, and cygrunsrv is installed from the 'Admin' category (the installer can be automated with command-line arguments)
  • Run CygWin as an Administrator and run ssh-host-config (this is a bash script, so you can make a similar script with the options you'd like pre-selected)
  • Note that if the machine is bound to a domain controller, local users won't be allowed to log in via SSH. More details on that here.
  • Generate an SSH key on your host with ssh-keygen -t rsa, then append the contents of the public key to ~/.ssh/authorized_keys for the guest's SSH user
  • You can now do a password-less login with ssh -i /path/to/.ssh/id_rsa ssh_user@windows_machine

When everything's done, you may want to add C:\cygwin64\bin\ to the end of your PATH (at the beginning it may override Windows default utilities with the same name). Any programs with an exe extension in that folder should work. When in doubt, you can always run bash from within CMD.EXE.

Another thing to note is that you can use the Windows native Python from within CygWin. When using the python command, the window appears to hang, but that's because Python can't recognize the console so it goes into non-interactive mode. To remedy this, launch the interpreter with python -i.

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