Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing CYGWIN + SSHD for remote access through SSH on windows
Installing CYGWIN with SSH
1) Download cygwin setup.exe from http://www.cygwin.com
- Execute setup.exe
- Install from internet
- Root directory: `c:\cygwin` + all users
- Local package directory: use default value
- Select a mirror to download files from
- Select these packages:
- editors > xemacs 21.4.22-1
- net > openssh 6.1-p
- admin > cygrunsrv 1.40-2
- Click continue
- When everything is installed configure SSHD
2) Configure SSHD
- open a cygwin terminal: start > RIGHT MOUSE ON "Cygwin terminal" AND "RUN AS ADMINISTRATOR"
- $ ssh-host-config
- Are you sure you want to continue: YES
- You have the required privileges: YES
- Overwrite existing /etc/ssh_config: YES
- Should privilege separation be used: YES
- Use local account 'sshd': YES
- Do you want to install 'sshd' as a service: YES
- name CYGWIN: just press enter
- Do you want to use a different name: no
+++ you can skip this ++
- Create new privileged user account (cyg_server): YES
- enter password
- reenter password
+++ end of skip ++
3) Add a SSHD account
- Open control panel
- Create a new account with administrator rights
- set a password for this new account
4) Add the user to SSHD password
$ cd /etc/
$ cp passwd passwd_bak
$ /bin/mkpasswd.exe -l -u [new_username] >> /etc/passwd
(for example: /bin/mkpasswd.exe -l -u roxlu >> /etc/passwd to add the password for roxlu)
5) Open SSHD port (22)
- Open control panel
- Click on System and Security
- Click on Windows Firewall
- On the left click on advanced settings
- click: select "Inbound Rules"
- click: New Rule ...
- [x] Port
NEXT
- TCP
Specific ports: 22
NEXT
- [x] Allow the connection
NEXT
- [x] Domain
[x] Private
[x] Public
NEXT
6) Trouble shooting
- first check if you can connect to the SSHD server on the same machine:
- open a Cygwin terminal
$ ssh -l [username] localhost
If you can't connect to the server on localhost check if the sshd daemon is running (see blow)
- check if the SSHD daemon is runing
- open control panel
- search for "services"
- click on "View local services"
- search for "CYGWIN sshd"
- make sure it's there, else try reinstalling sshd
@faughnn

This comment has been minimized.

Copy link

faughnn commented Oct 30, 2015

I was hoping to find an automated process for this as I need to do this on 20+ machines. No luck

@JavaScriptDude

This comment has been minimized.

Copy link

JavaScriptDude commented Apr 2, 2016

Nice walkthrough.

You may want to add a line for starting the sshd service like: net start sshd

On a new install, sshd service is not started automatically.

@wrlee

This comment has been minimized.

Copy link

wrlee commented May 11, 2017

I have ssh set up. I have a problem accessing LAN resources (servers, etc.). net view works, but trying to access any net servers gives an error. Even net use doesn't work. Network resources that are normally mounted are unavailable when I ssh in. What am I missing?

@DRSDavidSoft

This comment has been minimized.

Copy link

DRSDavidSoft commented Jun 8, 2017

This tutorial is really helpful. I appreciate you sharing it :)

@theddaywork

This comment has been minimized.

Copy link

theddaywork commented Oct 16, 2017

You can also start sshd from a Cygwin shell with cygrunsrv -S sshd
if you prefer.

@li-wu

This comment has been minimized.

Copy link

li-wu commented Nov 28, 2017

I have written a PowerShell script just for your reference: https://gist.github.com/li-wu/d7f1e536fd0fb95ed2c41a155565dd5a

@Eno77

This comment has been minimized.

Copy link

Eno77 commented May 3, 2018

Somebody got an issue with disappearing SSHD service in windows 10 1803?
I had everything set up and running in 1709.

If I run the command again, it says:
*** Info: Sshd service is already installed.

But it is not shown in Windows Services anymore. (And I cant connect either).

Reinstall everything?
The privileged Account is still there...

@ggets

This comment has been minimized.

Copy link

ggets commented May 14, 2018

@Eno77 I've got the same problem with 1803. The service is missing. Running sshd itself works. Definitely a problem with the service.

@ggets

This comment has been minimized.

Copy link

ggets commented May 14, 2018

@Eno77, do you happen to have a WSL installation on the 1803?

@ggets

This comment has been minimized.

Copy link

ggets commented May 14, 2018

I found the culprit. Cygwin's OpenSSH (sshd) service is conflicting with Windows' one. To fix that I edited /usr/bin/ssh-host-config and changed service_name=sshd to service_name=cygsshd and then rerun /usr/bin/ssh-host-config. Not sure where to report this issue, though.

@octimis

This comment has been minimized.

Copy link

octimis commented Jul 28, 2018

There is no passwd file in the, cygwin64\etc, directory.

@adebiade

This comment has been minimized.

Copy link

adebiade commented Jul 29, 2018

I have downloaded and configure ssh via cygwin did I suppose to use Cygwin to run ionic pro instead of cmd, because while i run ionic pro on cmd i have an error of : ionic ssh setup [WARN] OpenSSH not found on your computer. [ERROR] Command not found: ssh
and from the app folder where i want the package to install, the package is not fully installed, there is no index page and other necessary files.

@JavaScriptDude

This comment has been minimized.

Copy link

JavaScriptDude commented Mar 23, 2020

Here are some alternate instructions from Oracle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.