Setting up Cygwin SSH server
Introduction
"Cygwin is a distribution of popular GNU and other Open Source tools running on Microsoft Windows. The core part is the Cygwin library which provides the POSIX system calls and environment these programs expect." - Official Cygwin homepage.
Deploying CDP applications to Windows machines is possible only if a Cygwin SSH server is running on the target machine and Rsync is available. This tutorial gives step-by-step instructions on how to set it up and how to configure the target environment.
Setting up Cygwin and SSHD
Download Cygwin
Download the appropriate version of Cygwin and save it somewhere on the target system. Click here to go to Cygwin download page
Install Cygwin
- Run the Cygwin installer
- Using all the default installation options go through the installation wizard until package selection page is presented.
- On the Select Packages page use the search bar to locate openssh, openssl and rsync packages under subsection All->Net. Clicking on the little refresh button of the package select the latest versions for both of the packages and click Next
- Finish the installation
This process installs a Cygwin terminal and the necessary files for setting up an SSH server.
Protect Windows with a Password
Login through a Cygwin ssh server may not work correctly unless the Windows account is password protected with a non-empty password. If the Windows account has no password or an empty password, make sure to set up a password for the Windows account.
Configure SSH Server
- Run the Cygwin terminal as administrator
- Type in the following command: ssh-host-config
You are prompted with some or all of the following questions:
*** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes
*** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes
*** Query: Should StrictModes be used? (yes/no) no
*** Query: Should privilege separation be used? (yes/no) yes
*** Query: new local account 'sshd'? (yes/no) yes
*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no) no
You should then be prompted with text saying that the host configuration was successful.
Start SSH Server (SSHD)
SSH server should be run as a user process invoked via Windows startup system (at user logon). If SSH server is run as a service or under user not currently logged into, then CDP GUI applications can not be shown. To run SSH server on Windows startup follow these steps:
- Go to "C:\Users\<USER NAME>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" or press Windows key + R, type shell:startup and select OK.
- Create a shortcut for the command C:\<CYGWIN INSTALL DIR>\bin\bash.exe --login -c '/usr/sbin/sshd'
- Restart Windows
After restart SSH server should be started as a background process and be ready for usage.
Note: If you had Cygwin already installed make sure you disable all SSH services that may collide with our setup.
Allow Applications Through the Firewall
The Windows firewall must allow applications to communicate through the relevant networks. When you want to run a new application on a Windows target, first Deploy it to the target. Then open an explorer window on the target machine. Navigate into the deployment folder1 and then start the application from there. Windows firewall will pop up a security alert dialog that it has blocked the app. Make sure to allow the application to communicate on the relevant networks, then click Allow access on the security alert dialog. It is usually enough to only do this procedure the first time you run an application.
1 The deployment folder is printed in the CDP Studio Application Output pane when the application starts up, similar to this:
13:41:19: Starting /home/<USERNAME>/TestRemoteSine/TestRemoteSineApp/TestRemoteSineApp.exe ...
Note: On a remote Windows target, the path above is relative to the cygwin installation typically found in C:\cygwin64\, so the full path for the above example is:
C:\cygwin64\home\<USERNAME>\TestRemoteSine\TestRemoteSineApp\TestRemoteSineApp.exe
See also How to set up applications to run automatically on windows.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.