Installing an SSH Server on Windows
Local port forwarding requires an SSH server running on the Windows machine. OpenSSH is provided as part of Cygwin which is an environment similar to Linux for Windows. Cygwin provides an install and update utility (setup.exe) to retrieve packages from the Internet. When you install Cygwin, select the OpenSSH package (available in the Net category). Once installed, complete the Cygwin configuration as shown below…
In My Computer -> Properties -> Advanced -> Environment Variables:
add the variable CYGWIN=ntsec tty.
add C:\cygwin\bin to the PATH environment variable.
Now configure Windows OpenSSH from a Cygwin console window using the “ssh-host-config” command as shown below:
$ ssh-host-config Generating /etc/ssh_host_key.
Generating /etc/ssh_config file
Privilege separation is set to yes by default since OpenSSH 3.3. However, this requires a non-privileged account called ‘sshd’.
Should privilege separation be used? (yes/no) yes
Generating /etc/sshd_config file
Host configuration finished. Have fun!
Now we need to create a local forwarded tunnel from Windows to Linux:
ssh -L 5900:127.0.0.1:5900 [email protected]
Use this command to forward port 5900 on the Windows machine (where the VNC viewer runs) to Linux host 192.168.4.1 (where the VNC server runs). The loopback interface address (127.0.0.1) must be used. If localhost is specified, connecting the VNC viewer to the loopback interface fails with the message: channel 2: open failed: connect failed: Connection refused Connect to the VNC server over the SSH tunnel To complete the procedure, start the VNC viewer on the Windows machine (pointing to the server at 127.0.0.1:0). At this point, the connection is forwarded from the Windows machine to the Linux VNC server. All network traffic is transparently encrypted by the SSH tunnel.