Cygwin - Install SSH Server in Cygwin

Sometime, you will want to have SSH server running in Cygwin. In order to run SSH server in Cygwin, you will need SSH Daemon (sshd) to be configured.

Below are some steps to configure Cygwin to run sshd

1. Open Cygwin and run ssh-host-config

2. During the configuration, it will ask the following question

a) Should privileges separation be used?

Enter yes

b) New local account 'sshd'?

Enter yes

c) Do you want to install sshd as a service?

Enter yes. This will allow you to log into Cygwin even when Cygwin window is not running

d) Enter the value of Cygwin for the daemon?

Enter ntsec

e) "cyg_server' will only be used by registered services. Do you want to use a different name?

Enter no. Default work well

f) Please enter the password

Enter a password for cyg_server user

g) After this, the installation should be complete.

h) Type net start sshd to start the service

i) Now, you can use any SSH client to connect to your Cygwin sshd via localhost with port 22

Troubleshooting

1. SSH client cannot connect to Cygwin sshd

Make sure sshd is running. You can check your Windows services to ensure the sshd service is running.

If sshd is not running, check the sshd service vis Services -> Logon. Change to Logon as Local System Account may help

2. Able to connect sshd vis SSH Client, however, authentication failed.

Use mkpassword to configure Cygwin account by creating a /etc/passwd from your system information

ie, mkpasswd -l -p "$(cygpath -H)" > /etc/passwd

See http://www.cygwin.com/cygwin-ug-net/using-utils.html#mkpasswd

mkpasswd may bring over your system password to /etc/passwd, however, the password may not be usable/understand by Cygwin.

So, you may need to use passwd command to change the user password. After this, you should be able to log into Cygwin via SSH client

Comments

Popular Posts