Wednesday, June 17, 2009

X11 forwarding over SSH in Slackware

SSH is a program for logging into a remote machine and for executing commands on a remote machine. It is possible to run X Window graphical applications over SSH also. X forwarding allows you to run remote X applications that open their windows on your local display.

To establish an X Window connection over SSH:

1. Make sure that openssh package has installed and ssh service is active on both server and client machines.
(OpenSSH is free version of SSH)

2. Login to server machine (remote computer) using SSH

ssh remote_user_name@remote_machine

and edit remote computer's /etc/ssh/sshd_config file as remote root adding following lines and save.

AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes


3. Restart ssh service on remote machine by executing following command as remote root.

/etc/rc.d/rc.sshd restart

4. On client machine (your computer), edit /etc/ssh/ssh_config file as root adding following lines and save.

ForwardAgent yes
ForwardX11 yes


5. To establish SSH connection with configured remote machine, execute following command from an X Terminal Emulator.

ssh -Y remote_user_name@remote_machine


6. After logging into remote machine, execute below command to check the value of display variable in remote host environment.

echo $DISPLAY

If you do not see anything when typing above command, set value by executing:

export DISPLAY=localhost:10.0

Now try to launch an X application on remote machine from client machine, for example:

xlogo &

* /etc/ssh/sshd_config and /etc/ssh/ssh_config files have required lines for X11 forwarding in commented form as system default. Instead of adding new lines, just uncomment related lines and check parameters.

* You need to open port "22" on remote network for WAN connections over SSH.

2 comments:

  1. I have been using Slackware for 2 years now. I have come close to despair many times, but for some reason I haven't given it up. (What are the alternatives?)

    From time to time I get across such fine blogs that enlighten me and show me that there is a reason why I persevere: It's great fun to be in control of the machine!

    Thank you for your wonderful explanation!

    Joost

    ReplyDelete
  2. Simple and elegant tutorial. Saved me a headache!

    Thanks!

    ReplyDelete