Anyone using *nix for a time will happen to have occasions when they will require a GUI. Sometimes, something as simple as doing an RDP connection. That being said, there are a few alternatives: VNC, RDP, etc. The one I was curious about and recently setup was Openssh + X-Forwarding. This information discusses how to access the Remote X-windows on a different terminal as well, which comes in handy.
Linux machine (to be used as the server) should have the openssh server installed already. if it doesn’t then you need to install it. For Debian/Ubuntu etc type machines, this is a simple apt-get install ssh
. Once it is installed, you have to ensure the following two options are enabled in the configuration file (/etc/ssh/sshd_config):
X11Forwarding yes
X11DisplayOffset 10
If you were required to make that change, then you need to refresh the sshd daemon. You can do this by simply HUP’ing the PID, which causes it to re-read its configuration file or you can stop and re-start the ssh daemon. As usual, there are a couple of different ways to accomplish this. I’ll list a couple. Any of them should be sufficient. If you receive an authorization warning, then you will probably need to run it as root, or use sudo.
PID=`cat /var/run/sshd.pid` ; kill -HUP $PID
ps -ef |grep [s]shd ; awk '{print "kill -HUP " $2}' |
/etc/init.d/ssh restart
service ssh reload
The next thing you will want to do is find an unused tty. By default tty12 is NOT typically used. This can be validated via the CTRL-ALT-F12 key sequence. If it isn’t used (and that key combination hasn’t been put to use for any kind of keyboard shortcut, then that can be used). First, run this on the Linux client machine:
X :12.0 vt12 2>&1 >/dev/null
Explanation of above command:
Run X under display 12
2>&1 (Re-direct Standard Error to Standard Output)
>/dev/null (Redirect to null device)
This will start X on tty12. Now that is running, you can open an ssh connection on that tty with the following command:
xterm -display :12.0 -e ssh -X user@host &
This will start an xterm window on tty12. If you hit CTRL-ALT-F12 you will see the terminal window open. It will be asking for your password at this point (unless you are using ssh-keys). Enter the password and you will be placed at the command prompt on that machine. If you wish to enter a GUI, simply type this command:
gnome-session &
This will start up the X-windows environment for that “HOST” on tty12. If you get it loaded, but don’t have a panel, no worries. Just type gnome-panel &
and you will have the panel show up. Simply minimize the x-term window and you will be able to work away.