X11 Forwarding with SSH
This is quite interesting - you can login to a remote machine with SSH, and have the GUI running on your local machine - just like VNC.
How? Here's a quick tutorial.
I'm assuming that you have:
Start xinit
The easiest way to do this is change the runlevel to 3 by logging on as root, then typing: "telinit 3".
If you're already running a graphical display on :0, then run this command: "xinit -- :1".
Connect with SSH
Connect to the server like this: "ssh -l $user -XC $host", where $user is your username, and $host is the server. -X specifies that you wish to enable X11 forwarding, and -C specifies that you wish to compress the data (that's optional).
Run a Program
Now you're connected, try running a program! xcalc is a good one, since it's small, and thus fast to respond - even over a WAN connection. If you dare, try running windowmaker or gnome over SSH.
Overview
This is an example of me connecting to cyborg (192.168.1.10) over my LAN.
colin@hybrid ~ $ su
hybrid colin # telinit 3
colin@hybrid ~ $ xinit
colin@hybrid ~ $ ssh -l colin -XC 192.168.1.10
colin@cyborg ~ $ xcalc
(calculator program runs as a GUI)
colin@cyborg ~ $ windowmaker
(windowmaker runs)
Have a lot of fun...
How? Here's a quick tutorial.
I'm assuming that you have:
- sshd working on the server
- ssh client working on the client machine
- X Server working on the client machine
- Some programs that use a GUI installed on the server (eg: xcalc)
Start xinit
The easiest way to do this is change the runlevel to 3 by logging on as root, then typing: "telinit 3".
If you're already running a graphical display on :0, then run this command: "xinit -- :1".
Connect with SSH
Connect to the server like this: "ssh -l $user -XC $host", where $user is your username, and $host is the server. -X specifies that you wish to enable X11 forwarding, and -C specifies that you wish to compress the data (that's optional).
Run a Program
Now you're connected, try running a program! xcalc is a good one, since it's small, and thus fast to respond - even over a WAN connection. If you dare, try running windowmaker or gnome over SSH.
Overview
This is an example of me connecting to cyborg (192.168.1.10) over my LAN.
colin@hybrid ~ $ su
hybrid colin # telinit 3
colin@hybrid ~ $ xinit
colin@hybrid ~ $ ssh -l colin -XC 192.168.1.10
colin@cyborg ~ $ xcalc
(calculator program runs as a GUI)
colin@cyborg ~ $ windowmaker
(windowmaker runs)
Have a lot of fun...

1 Comments:
Actually things are easier than that:
% ssh -X -C user@host
If "X11 forwarding" is enabled on the server (SSHD) side (in sshd.conf file), then when the above is executed the default display is "localhost:10";
use
% echo $DISPLAY
to see this.
Then just execute whatever X app you wish to use (xcalc or xterm or mozilla or whatever).
Post a Comment
<< Home