Introduction: Use SSH and XMing to Display X Programs From a Linux Computer on a Windows Computer
If you use Linux at work, and Windows at home, or vice versa, you might at times need to log in to the computer at your other location, and run programs. Well, you can install an X Server, and enable SSH Tunneling with your SSH Client, and one-up both VNC and Remote Desktop, for speed and usability.
This 'ible covers using sourceforge.net/projects/xming/ and www.bitvise.com/tunnelier as your Windows solutions, and Openssh for the Linux side. On a side note, all of this can also make use of LogMeIn Hamachi as an easy-to-use VPN.
Step 1: Set Up Your SSH Client
In this step, we'll set up your SSH Client. First, install your copy of Bitvise Tunnelier, and start it up. You can create a connection profile with the Linux server's IP address or hostname, and optionally automatic login information. The next part of this step is filling out the ports to be forwarded via SSH. For the Windows X Server, we'll forward the linux box's port 6010 to the windows box's port 6000, where XMing will run. This way, Linux's own X Server can run undisturbed, at port 6000.
Step 2: Install XMing, the X Server for Windows
Run the installer program for XMing. Next, start up XMing in the background. You can skip the configuration options, as the defaults should be fine.
Step 3: Make Sure That OpenSSH Is Installed on Linux
On your Linux Computer, make sure that OpenSSH is installed and running. For Ubuntu, you can simply run "sudo apt-get install openssh-server" in the command terminal. Other Linux Distributions will differ.
Step 4: Add an Automatic "DISPLAY" Variable for the Linux Computer
Add the following lines to the end of the file in "${HOME}/.bashrc":
if [ -d "${HOME}/bin" ] ; then
export PATH="${PATH}:${HOME}/bin"
if [ -f "${HOME}/bin/ssh_login" ] ; then
. "${HOME}/bin/ssh_login"
fi
fi
Next, create the file "${HOME}/bin/ssh_login". Create the file with the following initial contents:
#!/bin/sh
if [ -n "${SSH_CLIENT}" ] ; then
if [ -z "${DISPLAY}" ] ; then
export DISPLAY='localhost:10'
fi
fi
After saving the file, run the following command: "chmod 777 ${HOME}/bin/ssh_login" to make the script executable. What this does, is points any X program started from a console that is logged in via SSH to the port that re-directs back to the SSH-Client PC, in this case, the Windows PC running XMing. This just saves us from typing the same "DISPLAY=" line every time you log in via SSH.
Step 5: Start Your SSH Client.
Start your SSH Session by clicking the "Login" button. After the initial authorization completes, and you accept any Encryption keys you need to, you'll likely have a command prompt window and a secure ftp window open. You can close the sFTP window, for now. To test your setup, run "xeyes" from the command prompt. If you see two big googley eyes following your mouse, with an X-Windows icon and window bar above them, then your setup is working!
Step 6: Linux-to-Linux Version
As an extra step, If you are trying to perform the same type of thing from a Linux Client, to a separate Linux server, that's very simple. Each computer should have openSSH Client and Server installed. On one of the computers, just run "ssh -l
The "-l
5 Comments
Question 3 years ago on Step 1
I am getting the error "Failed to invite server-configured server-to-client port forwarding ". Please help.
3 years ago
Hi, i only have one doubt, when youre able ti log on Linux whit xming, how do you write @ on Firefox?
13 years ago on Introduction
Nice Instructable. I used to use a similar process to confuse the heck out of people in the Sun Spark station lab in college. Just rsh into someone else's machine in the lab, redirect the display to your own machine, and run a media player. You should see the looks on people's face when the computer they're sitting at mysteriously starts to "moo" or play music...
Reply 9 years ago on Introduction
There's a better way... SSH into the station, wget a nice file and use xmms2 or any other CLI player :)
Reply 13 years ago on Introduction
Haha! I approve. That's a nice prank, making someone's workstation moo at them. I've never worked (or had at school) an environment where I wasn't the only one on a unix machine, so I haven't had that opportunity. Windows is just so prevalent on Desktops...