Monday, June 1, 2015

Connect in graphical mode to remote linux server from Cygwin/X

Connect in graphical mode to remote linux server from Cygwin/X 
(and from windows terminal services client and vncviewer clients)

A very simple and basic howto
(last updated on jun 2 2015) 

Windows "client" with a local installation of cygwin/X (download from
Remote linux server, with graphical display capability.

Basic application access
  1. on remote linux, you need to have the "X11Forwarding yes" line in /etc/ssh/ssd_config
  2. run cygwin64 terminal on workstation, from there launch "startx"
  3. open a local terminal in the Cygwin/X:0.0 window (right click, open terminal here). From the terminal, the command "set | grep DISPLAY" should show DISPLAY=:0.0 (these 0.0 represent the display number and the visual number)
  4. from the terminal, run "ssh -Y user@remotelinux-address" and insert password. You should now get to the remote system in the same terminal window.
  5. from the terminal window, run "xterm", or any other graphical application. After a moment you should see the window come up.

Connection to main graphical login screen (to properly see complete desktop)
This setup requires proper configuration of XDMCP (X display Manager Control Protocol)
  1. On the remote linux you need to run a display manager that talks xdmcp. I was successful using xdm or gdm3. (for gdm3, on kali linux, I had to set enable=true in the [xdmcp] section of /etc/gdm3/daemon.conf)
  2. From windows cygwin command prompt run xlaunch (do not run startx), then choose open session via XDMCP. this sends some UDP datagrams to port 177 of linux server, after a while, traffic starts flowing in towards local workstation tcp port 6000 (X traffic). You need to have quite an open routing between the workstation and the remote server in order for this traffic to work. A non working symptom is that you just see a black window on your workstation screen.
  3. With these steps I had the keyboard perfectly working in the graphical terminal, and cut and paste to and from the graphical terminal is working well, even with non-ascii accented characters.

My configuration: 
Workstation: Windows 8.1 64 bit english
Remote linux: kali linux 1.1.0


Other remote graphical options:
the following options do not require the cygwin/X environment, but just a simple graphical bitmap client.

- xrdp: remote desktop protocol
  1. install xrdp on remote linux server 
  2. in remote linux server, start the xrdp service with "service xrdp start" (this starts the listener on the tcp:3389 port)
  3. from windows workstation, run mstsc (remote desktop connection), and login on the graphical page you will get. This will allow graphical login and full remote desktop visibility, with menu and applications

- xvncserver / vnc4server: virtual network computer
  1. install vnc4server on remote linux server
  2. launch vnc4server on remote linux server from a terminal session, define graphic resolution and define a password, and take note of the port identifier assigned to the new session listener. be it n. This starts the listener on tcp port 5900+n
  3. from windows workstation, launch vncviewer client and direct it to open a session on the linux server host, on the destination tcp port 5900+n. If n=1 then it is 5901
  4. when done, remember to kill the vnc4server with "vnc4server -kill :n"