Skip to content

Instantly share code, notes, and snippets.

@roxlu
Last active October 8, 2024 10:59
Show Gist options
  • Save roxlu/5038729 to your computer and use it in GitHub Desktop.
Save roxlu/5038729 to your computer and use it in GitHub Desktop.
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
@ggets
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
Copy link

octimis commented Jul 28, 2018

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

@adebiade
Copy link

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
Copy link

Here are some alternate instructions from Oracle.

@seyedmmousavi
Copy link

If you can not connect remotely, try to change default port through sshd_config file and restart service.

@sarnobat
Copy link

net start sshd

Thank you, this is what I needed.

@SakeebHossain
Copy link

Saved me! Thanks

@emptypockts
Copy link

how do I know the password? I can reach the local host and I get the login prompt but I don't know which user and password to use. where I can see that or can I create a default user to login locally ?

@JavaScriptDude
Copy link

By default, I believe that all users are authorized to use SSH so the username and password is the windows username and password. You can update the sshd_config file to restrict accounts but the password is always the windows password. There may be a way to bypass that but I've always used it in this way.

@emptypockts
Copy link

Thank. I tried my user with my password, and it didn't work, I tried my user with domain and password, and it didn't work either. I believe that my laptop has some security policies that don't allow me to make this setup.

@JavaScriptDude
Copy link

The sshd logs should give hints on the issue. There could be some policy or other( anti malware/virus tools?) at play. Check this out for logging.

@petemoore
Copy link

petemoore commented Jan 25, 2023

@faughnn

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

See https://petemoore.github.io/general/taskcluster/2016/03/30/windows-sshd-cygwin-ec2-aws.html (although I realise I'm pointing this out 7 years after you asked!!!) 😆

@roxlu
Copy link
Author

roxlu commented Jan 26, 2023

I love it that these gists are still read and maybe are usefull to someone.

Meanwhile you could also check the built in server which is part of Win 10.

@faughnn
Copy link

faughnn commented Feb 2, 2023

@faughnn

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

See https://petemoore.github.io/general/taskcluster/2016/03/30/windows-sshd-cygwin-ec2-aws.html (although I realise I'm pointing this out 7 years after you asked!!!) laughing

lol brings me back. First week of a job I've long left

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