For Linux or other Unix-like systems, graphical interface / applications rely on the "X" (X window). Thus for a command-line user who wants to start a remote graphical application, he/she will needs a X11 server on the local machine to forward these graphical data through the X11 protocol. And display the result on the local machine.
Since the X11 transmission is not encrypted, make it vulnerable to snoopers. To solve this problem, we can use the SSH protocol, which encrypts everything in and out, to secure our connections. In the context below, I will show how to set up a "tunnel" for transmitting X11 data over SSH (also known as SSH Tunneling). Please follow these steps:
*These are my personal experience, please let me know if something is not correct!
1.Prepare your SSH client ( Here I use PieTTY, you may also use PuTTY to do the same thing.)
2.The following option in /etc/ssh/sshd_config on your server must be enabled. Will automatically set the DISPLAY variable to localhost:10 for you.
(You need to Enable X11 Forwarding in your pietty/putty.)
*The SSHD service must be restarted after any modification.
3. Prepare your X windows Server, e.g. ReflectionX / Xming / VNC Viewer / X-Deep. I will show three of them here.
In my own opinion, ReflectionX is easiest to use but it's not a freeware and needs more memory. VNC Viewer is portable, lite, but elaborate. Xming will be a good choice only if the environment is well-configured.
ReflectionX | ||
PROS: Easy to use, with screen shot function. | CONS: Fat, not a freeware, not portable. | |
Leave ReflectionX along after startup, login your server with PieTTY and enter:
For BASH shell users, if you are using your own account, you can add this line into ~/.bashrc, or by using the command: declare -x DISPLAY=YOURIP:0 to set this configuration to be one of your environment variable. (If you are a C-shell user, use setenv DISPLAY YOURIP:0 instead) If you would like to have ReflectionX minimize to tray, click "View" -> "Hide Taskbar Icon on Minimize": Note-test result on my cluster:idt - OK / GrADS 2.0.1 - OK / Vis5D 5.1 - OK / Vis5D+ 1.3.0B - OK |
||
Xming - (memory usage≒15 MB) Official link | ||
PROS: Consumes lesser memory, freeware. | CONS: Not portable, needs extra settings on the server. | |
There are two ways to use it: ●If the "X11DisplayOffset" and "X11UseLocalhost" have been set in the sshd_config file: Switch to PuTTY mode in your PieTTY: Note: please commenting out the "export DISPLAY=YOURIP:0" in your ~/.bashrc, the X11UseLocalhost setting will setup the DISPLAY variable for you automatically. ●If those two variables mentioned above are not available, and you can't modify it.... Find the shortcut of Xming in the startup menu after it has been installed, right click on the link →Properties, add "-ac" into the startup parameter box like this: WARNING: Due to security concern, only use this argument under a trusted network! Just like using the ReflectionX, you don't have to modify the client, but use export DISPLAY=YOURIP:0 instead (to set the environment variable, please refer to this part in ReflectionX). The following error messages appear with the lack of the "-ac" argument in the startup parameter box:
Reference:http://www.dbuggr.com/smallwei/resolve-xlib-connection-localhost-0-0-refused-server-error/ Note-test result on my cluster: idt - OK / GrADS 2.0.1 - OK / Vis5D 5.1 - OK* / Vis5D+ 1.3.0B -FAILED |
||
VNC Viewer - (memory usage≒5 MB) Official Link | ||
PROS: Memory-friendly, freeware, portable. | CONS: Complicated to configure. | |
After login into the server, startup the VNC service by "vncserver" command, and you might see these: New 'HOSTNAME:1 (USERNAME)' desktop is HOSTNAME:1
Number "1" means the 1st display screen, it continues when starting another vncserver. This is how you connect with VNC Viewer (Without SSH tunneling)
In order to protect the connection, you have to do something like those for Xming, switch to the PuTTY mode in your PieTTY, then go to > "Connection" > "SSH" > "Tunnels". Specify the port that you will allow VNC Viewer to use on your computer. (In this case: 1234) Now you can connect to your server, don't forget to start the vncserver.
Reference: http://senkao.pixnet.net/blog/post/23633976-透過ssh通道連結家中
ubuntu主機的vnc-server |