Saturday, February 4, 2012

Connecting X11 without ssh

I have a situation where ssh -X is too limiting for what I need to do.

I have the ability to sudo to any user account on a remote Linux machine.
I am not able to log in as root.

ssh -X works perfectly for connecting as me to the remote machine. I am able to open X windows programs. Once I change to another user, I am unable to execute X windows programs.

I found a solution after reading several helpful posts:
http://hints.macworld.com/article.php?story=20081208062918906
http://dragonwall.net/xdeep-putty.html

I enable X11 listening on my Mac.
defaults write org.x.X11 nolisten_tcp 0
If xwin is running, stop it and restart it.

At first, I opened port 6000 to allow access to the display. After reading the comments about opening port 6000 through the firewall, I realized I needed to connect via the VPN to the remote computer.
http://www.publicvpn.com/support/MacOSX105.php

I connected to my VPN. The link above did not use PPP, so I had to make that modification to the steps. I was able to connect.

I am using a Mac, so I could open a terminal. The prompt at the terminal window indicated that I was connected to the VPN. I issued ifconfig to get the local ip address from the VPN.

I issued ssh to connect to the remote computer. I did not use -X, since tunneling will not work when I change to another user.

At the remote command prompt, I set the display environment variable to the ip address of the local VPN address, adding :0 to the end.
setenv DISPLAY xxx.xxx.xxx.xxx:0

I tested opening an xterm as me. It worked.

I changed to a different user and opened an xterm. It worked.

I checked that the firewall was still blocking port 6000. The port is only accessible through the VPN.

After all this, opening the application that I need takes too much time. It will be faster to drive to the remote location and log into the machine to do the work I need to do.

I will disable X11 listening on my Mac.
defaults write org.x.X11 nolisten_tcp 1



Next attempt.

I have the MS Office suite on my Mac. It has Remote Desktop Connection. I can use it to log into the remote computer.

The remote computer is Windows 7, but it has cygwin installed on it. I followed these steps:
  1. Connect to VPN.
  2. Remote Desktop to remote Windows 7 computer (local.name).
  3. Open cygwin bash shell.
  4. Issue startxwin command in /usr/bin
  5. Open xterm
  6. Enabled xhost connections for remote Linux host (remote.name): xhost +remote.name
  7. ssh without X11 tunneling to remote Linux host.
  8. Set DISPLAY to local.name:0
  9. Change to different user and open xwin application.
  10. The GUI app opened immediately.

No comments:

Post a Comment

Followers