Hands on X11
Pages: 1, 2
Networking X11
In the old days, your big Unix servers ran all of the applications, and you used an X Terminal (a machine with a screen and keyboard but no hard drive or CPU of its own) to use those applications.
Today most Unix systems (Mac OS X included) still support this
functionality. Let's go back to your open xterm window. In order to
allow other systems to display their applications on your screen, you must
first give them permission to do so. You do this using the xhost program
(you can learn more about the xhost command by typing man
xhost at the xterm prompt). From the command prompt in xterm, type
xhost and press return. Unless you've already modified the default
permissions of your system, you'll most likely see a message like this:
access control enabled, only authorized clients can connect
What this tells us is that your system will only let authorized
computer systems display X11 applications on your system. For security
purposes, this is a very good thing. You wouldn't want someone displaying
applications on your system without your authorization. In order to allow
other machines to do this, you need to grant them access from the prompt.
For example, I'd like to allow Gomez, a FreeBSD server without a monitor
or keyboard, to display it's applications on my Mac. Gomez's IP address
is 10.0.1.204, so I type xhost +10.0.1.204 at the prompt, and
it responds with
10.0.1.204 being added to access control list
Alternatively, if I'm sure that my network is secure behind a firewall,
and I'm not worried about possible security issues, I could also have
typed xhost + at the prompt. This allows any and all
machines to use my Mac's display. The system would respond with
access control disabled, clients can connect from any host
Now I'm ready to launch an application from the remote system. I've
ssh'd to Gomez, where an entire X11 distribution and additional
applications are available to me. So, let's launch something simple,
xclock for example, and watch it appear on my Mac. I type xclock
& at the Gomez command prompt and press return, but instead of
seeing an xclock appear on the Mac, I get this error:
Error: Can't open display:
The cause of this error is that all X11 systems, by default, will try and use their own display for any X11 applications you launch. In the case of Gomez, there is no keyboard, mouse, or monitor, and no X Server running. So I need to tell Gomez to use my Mac's display instead. The Mac's IP address is 10.0.1.2, so, from Gomez's command prompt, I type:
export DISPLAY=10.0.1.2:0
I use the export command for this because I'm running the bash shell. If I were running the tcsh shell, I'd have typed:
set DISPLAY=10.0.1.2:0
In either case, unless something went wrong, the system should return a command prompt, and you're ready to go. This command tells the remote system to use the first X Windows display running on the machine with the IP address of 10.0.1.2. In other words, it treats the Mac as if it were its very own monitor, keyboard, and mouse. Now, we type:
xclock &
This time, instead of an error, Gomez returns a process number (we ran the program in the background using the & symbol) and we see the xclock display on the Mac.
|
|
Neat, but not exciting. And we've already got the xclock application
on our Mac. On this Mac, we use Safari, Camino, and Internet Explorer,
but don't have Mozilla installed. Wouldn't it be neat to run FreeBSD's
Mozilla on the Gomez and have it display on the Mac? From the command
line, we type mozilla &.
The server responds with a process number, and after a few moments, Mozilla appears on the Mac's screen, as shown in this screenshot. Notice the un-Mac-like fonts, and the information on the about page which lists "FreeBSD i386" as the build version. This is because Mozilla is actually running on the FreeBSD server and is merely being displayed on the Mac.
X11 can be used to manage many remote Unix systems in this fashion, an unlimited amount, actually, all the while keeping your Mac's system resources low (only the X11 application runs locally). This is very handy when running applications on Unix systems that lack a monitor and keyboard but require a graphical display. The Oracle installation program is an excellent example of this type of application.
Final Thoughts
We've only just scratched the surface of X11's true potential. Not only do you now have the ability to run a huge collection of X11 applications on your Mac, but you can also run an X11 application from any Unix system you can connect to.
Dan Benjamin is a business strategist, programmer, writer, interface designer, and photographer.
Return to the Mac DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 34 of 34.
-
X11 window too big
2003-08-19 19:40:19 anonymous2 [Reply | View]
I have X11 running on my FP iMac. The xwindows app I am using creates a window that is taller than my display. I can't access the controls at the bottom of the window because they are off the screen. Does anyone know a way around this? I really want to use this app.
Details
FP iMac display 1024x768
OSX 10.2.6
xwindows app running from Solaris 2.5.1
-
X11 and $DISPLAY issues
2003-06-25 12:33:23 anonymous2 [Reply | View]
Hi,
I've tried almost everything I can think of to get Xapps to display on my Mac (ver 10.2.6) using X11 (ver Beta 3 - XFree86 4.2.1). I am connecting to a Unix network, but I have to connect remotely through a separate network (I'll call it school) to get to the inside network... Looks sort of like:
ssh school.edu
username
passwd
ssh department.edu
username
passwd
I am able to connect to dept.edu just fine, but when I try to run any xwindow (say xclock) I get the error:
X11 connection rejected because of wrong authentication.
X connection to localhost:10.0 broken (explicit kill or server shutdown).
I have tried using "setenv DISPLAY IP:0" and variations on it and nothing seems to work.
I am connecting thru DHCP with router at a local coffee house.
Even the network administrator at dept.edu gave me full permissions to dept.edu under the specific IP I have right now, but I think the router is getting in the way and dept.edu doesn't recognize the IP I am at because of the router. Does that make sense? When I try to ssh directly to dept.edu (which theoretically I should be able to do because I have the full permissions), I recieve the error:
ssh_exchange_identification: Connection closed by remote host
That's why I think the router is getting in the way. I have checked sshd_config and X11forwarding is set to "yes" (on my laptop, on the school.edu account, and on dept.edu).
I know this is a little confusing, but if anyone can help out or has any suggestions, I would REALLY appreciate it!
Thanks for your time,
Sara -
X11 and $DISPLAY issues
2003-09-18 07:22:05 anonymous2 [Reply | View]
I have the exact same problem and I haven't been able to resolve it yet either. Like you, I tried all kinds of things and checked all the ssh configuration stuff on both ends. It just doesn't want to go. I wish someone could provide some useful advice!
Ein
-
Problems here, too.
2003-06-13 09:14:00 anonymous2 [Reply | View]
I've not been able to get this to work, either. Using the method described in the article, I get:
[G4-Server:~] mmayer% xclock &
[1] 2186
xclock: Command not found.
logout
[1] Exit 1 xclock
Connection to 192.168.1.107 closed.
Using Paul's method:
[Mark-Mayers-Computer:~] markmayer% ssh -X mmayer@192.168.1.107
mmayer@192.168.1.107's password:
Last login: Fri Jun 13 08:53:55 2003 from 192.168.1.101
Welcome to Darwin!
[G4-Server:~] mmayer% xclock &
[1] 2202
Connection to 192.168.1.107 closed.
Maybe I'm doing something incorrectly.
Also, pardon the attitude, but saying this tutorial is for "Power Users" Only is a complete crock. Some of us beginners are using these tutorials on our path to PowerUserhood, and we need better step-by-step instructions. We might not be your intended audience, but we buy O'Reilly books too. I bought OS X Hacks after using Kevin Hemenway's excellent OSX Apache tutorials. (I also started using Rael's Blosxom around that time.) </rant>
Anyway, thank you for the tutorial, but it's just not working for me.
-
set in tcsh
2003-05-08 12:39:29 anonymous2 [Reply | View]
The comment in this article about how to set the DISPLAY variable if you are using tcsh as your shell (any c-shell applies, though) reads:
set DISPLAY=10.0.1.2:0
As an experience tcsh user, I would never set a variable in this manner. Instead, I would type:
setenv DISPLAY 10.0.1.2:0
Note the absence of "=" which you must omit. The big differance is that the second form writes the variable into the environment, where the first form does not. On some OS's, the example presented in the article would work, but as a user moves into using that system more fully they will begin to experience strange behavior. This is due to environment variables being "masked" by local variables.
I never teach people to use commands that do not work universally, if I can help it.
Lamont R. Peterson <lrp@xmission.com>
-
X11 and SystemPrefs: Networking
2003-04-30 08:45:51 anonymous2 [Reply | View]
Right now I only have my macs connected via a simple ethernet switch that I use to shuttle files back and forth via the Finder->Go->Connect To Server menu, mounting disks as needed.
Do I understand correctly that I actually need a router in order to network my machines together so that I can use their IP addresses in the manner discussed here? -
X11 and SystemPrefs: Networking
2003-05-08 13:06:56 anonymous2 [Reply | View]
The short answer: Absolutely NOT!
The details: Your machines need to be able to alk to each other over the network using TCP/IP. If you have not setup TCP/IP on your machines (which would be weird because you wouldn't be able to get to the Internet over your network) then you need to do so. It doesn't matter if you tell each computer what IP address to use or let DHCP do it for you. If you use DHCP, then make sure that you can resolve hostnames, like this:
[command prompt] % host mycomputer
...and that should return the IP address set by DHCP. If that doesn't work then I would recommend getting a conversation going with someone like myself, who can talk you through some of the things that you could do to fix it up. The main thing to do here is make sure that your DHCP server and DNS server programs will talk to each other. This allows DHCP assignments to be recorded and available via DNS requests.
Once you have your hosts resolving properly, you can do this on the REMOTE host (this is for a tcsh shell):
[command prompt] % setenv DISPLAY mycomputer:0
By using the computer's name, your connection will still work even if DHCP changes the machines IP address (assuming that your DHCP server is working correctly to report such configuration chages to your DNS server). This is especially nice in that you do not have to think about the IP addresses at all (once it is all up and running), just machine names (which are easier to remember and work with).
Lamont R. Peterson <lrp AT xmission.com AND_NOTHING_ELSE.net>
-
Yes, but how do I run Mac OS X apps through X?
2003-04-26 05:47:15 anonymous2 [Reply | View]
I'm looking to export my Mac's display to another system, so that when I run apps (X11 apps, of course) on my Mac, they'll display on my PC's X11 server. Or my Linux boxes. Over SSH.
When I ssh -X to my OSX box the DISPLAY variable is not set, as in this example from xterm on my OSX box:
[bkoehn@g4 foo]$ echo $DISPLAY
:0.0
[bkoehn@g4 foo]$ ssh -X localhost
bkoehn@localhost's password:
Last login: Sat Apr 26 07:44:00 2003 from localhost
Welcome to Darwin!
[bkoehn@g4 foo]$ echo $DISPLAY
[bkoehn@g4 foo]$
Any ideas on how to fix this?
-
Something is still missing
2003-04-09 12:24:28 anonymous2 [Reply | View]
I have followed the directions above and in the one post, followed the alternative options for ssh. When i connect to the server, and run
xclock &
I get what looks like a process ID but then message saying it can't be found.
What I can't seem to find anywhere is what installation or setting needs to exist on the remote machine in order for X11 to even work with a remote X Server (the Mac desktop).
If the clock can't be found, does this mean that it isn't installed, the user login doesn't have it in their home directory? etc....
-
Do not use XWindows across network WITHOUT ssh
2003-04-07 20:21:36 csoto [Reply | View]
XWindows sends every key click and mouse action across the network, in the clear. This is bad. No big deal if it's localhost, but skip all of the xhost & DISPLAY stuff.
Here's a quick HOW-TO (assuming you're using OpenSSH or a similar build, like that on Solaris or HP-UX):
-Modify /etc/ssh/sshd_config on the REMOTE HOST so that it says "X11Forwarding yes" (remove the # at the front) [you probably have to be root, so use su or sudo]
-Restart the REMOTE HOST [yes, there are other ways, but I have no way of knowing whether your sshd is started by rc scripts or inetd, so this method always works :) ]
-Modify /etc/ssh/ssh_config (note the missing 'd') on the LOCAL HOST (the Mac on which you're running X11) so that it says "ForwardX11 yes" (remove the # at the front) [you can skip this, but it means you will have to remember to use the -X option any time you run ssh ]
Now, when you connect to the remote host, use this command:
ssh -X user@remotehost
You can skip the -X if you modified your Mac's /etc/ssh/ssh_config as above.
Note that not all X clients will work in tunneled SSH sessions. See http://www.snailbook.com/faq/ under "X Forwarding" for some possible reasons and solutions.
Interestingly, X11 for Mac OS X seems to be more compatible with my Sun, SGI, Linux and HP-UX hosts than they are with each other. HP-UX clients particularly barf when I access them on the Sun. It's so nice having a wireless Unix laptop :)
Charles -
X11, Xhost and Display
2008-04-09 06:59:31 leousr [Reply | View]
So about a month ago, I started having a completely new random problem without changing anything myself...
When I login using ssh -X or ssh -Y I can't get my the X11 DISPLAY forwarding to work without the xhost +x command (on the mac).
I am logging into a linux box from Leopard. I am wondering if -- Some security update might have changed something
Any ideas? It was all working a month ago. (I have all the X11 forwarding stuff set, etc)
-
Gdk-Error???
2003-04-03 08:49:16 anonymous2 [Reply | View]
Hello Dan Benjamin,
I've a Question about X11 on MacOSX.
I can start NMAP on X11,but everytime I hit the "Scan"-Button,NMAP closes and I get this Warning in xterm:
Gdk-ERROR **: X connection to :0.0 broken (explicit kill or server shutdown).
Do You know what it means and what to do,so NMAP works fine??
Every Help is useful!
Thanks Alf
-
ssh?
2003-03-25 10:07:48 anonymous2 [Reply | View]
Dan, you wrote "I've ssh'd to Gomez". Can you explain how you did that, I couldn't find it in the article.
thanks,
Koen -
ssh?
2003-03-30 13:06:23 anonymous2 [Reply | View]
ssh is like "telnet" except it's secure. Gomez is obviously a machine name.
just type 'ssh <machine>' from a command prompt. Or type 'man ssh' to see what ssh is all about ;-) -
ssh?
2003-03-31 18:07:38 anonymous2 [Reply | View]
Following your advice, I get this output:
% ssh Gomez
ssh: Gomez: no address associated with hostname.
I'll try to delve through the man page, although they seem to be written for powerusers, not for someone who is interested in a 'Hands on X11' article. -
ssh?
2003-04-17 15:08:44 anonymous2 [Reply | View]
The server "Gomez" is running on the author's network. The whole "remote X11" stuff ONLY makes sense if you have multiple servers to manage. This is generally "power users".
While X11 on Mac is neat, it is probably not the best "learning environment" in much the same way as learning to drive on a automatic transmission car is probably not the best training for getting accustomed to logging trucks...
-
Cannot Find Command
2003-03-19 11:25:19 anonymous2 [Reply | View]
I am geting a "cannot find command" error when I try to run an x11 app over a server. I have an iBook and an iMac in the same house on the same router. They can ssh to each other just fine. When I try to run xclock, xeyes, or any other X11 command I receive the "cannot find command". I tried to set a path to /usr/X11R6/bin/ but it did not work. When I check the host computer (iBook) the $PATH variable does show /usr/X11R6/bin as a path. However, when I tunnel in through ssh on the iMac /usr/X11R6/bin/ is not listed in the path variable. Solutions?
I can run the command doing the full path of:
/usr/X11R6/bin/xeyes
Thanks,
MactOSiX
-
How to Completely remove X11
2003-03-17 23:39:12 anonymous2 [Reply | View]
In terminal. Don't write lines starting with a sharp
# Binaries, Libraries, fonts
sudo rm -Rf /usr/X11R6
# Configuration files
sudo rm -Rf /etc/X11
# Application
sudo rm -Rf /Applications/X11.app
-
on X
2003-03-17 09:47:59 anonymous2 [Reply | View]
is it possible to use OS X this way? i.e. i have an old g3 that's my server. but when i run package's, they want a display to render the interface on. can i do this with X11 or do i have to buy Apple Remote Desktop?
thanks!
-
Use ssh -XC user@host.name instead
2003-03-17 07:17:35 anonymous2 [Reply | View]
As Paul mentioned below, much better than mucking with xhost + and tweaking your DISPLAY variable on the remote system, is letting SSH do it for you:
ssh -X user@host.name
which tunnels X11 through an encrypted SSH channel, meaning that
(1) after you SSH, you can run X11 apps without any more setup
(2) your security is much tighter than allowing any X11 from the remote IP to connect to your display
(3) you can work around firewall problems
Really there's no reason to use the method mentioned in the article.
Mithras
-
Enivronment variables
2003-03-16 17:30:15 anonymous2 [Reply | View]
(Take two... ahem....)
It would be preferable to dispense with the X11 xterm altogether, and work through one's customized Terminal.app setup. So what environment variables need to be set, as X11 reportly does already, so that X-windows programs can be launched from Terminal? What is the best way to set these variables? What are the possible adverse consequences? TIA. -
Enivronment variables
2003-03-17 04:43:12 danbenjamin [Reply | View]
The two most important settings are PATH and DISPLAY. You'll need to add:/usr/X11R6/binto your PATH variable, and will need to create a new shell variable, DISPLAY, and set it to:0.0
In bash, you'd do this:
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/Users/username:/usr/X11R6/bin
export DISPLAY=:0.0
If you're using tcsh, you'd do:
set PATH=/usr/bin:/bin:/usr/sbin:/sbin:/Users/username:/usr/X11R6/bin
DISPLAY=:0.0
Be sure to replace username in the above examples with your own username.
Now, after launching X11, you should be able to run commands from the Terminal window instead.
Good luck.
-
Enivronment variables
2003-04-23 14:08:01 zankl [Reply | View]
I included the tcsh lines you posted in my home/.cshrc file. However, I still get an Error:can't open display when I try to launch xeyes for example. When I echo $DISPLAY I get :0.0 so everthing seems to be allright. Any ideas whats going wrong?
Thanks
Andreas.
-
uninstalling x11?
2003-03-16 14:25:08 anonymous2 [Reply | View]
How can I completly uninstall Apple's X11?
-
Running GNOME?
2003-03-15 13:50:26 anonymous2 [Reply | View]
Hey,
Thanks for your article. I'm curious as to how to go about running GNOME "properly" from my mac. I used Paul's method of ssh -X into my linux box (since your method wasn't working correctly, see other post). I ran gnome-session and it took over my desktop and replaced it with it's own, created the panel, opened up my previous session settings and so on. When I killed gnome-session though, the gnome desktop and panel stayed there, fully usable. I tried disconnecting from my ssh session, which made the xterm I was running it from hang. I quit the X11 app, and all was well, but I'd like to know the proper way of shutting dwon gnome?
Thanks,
Harold
-
I'm Getting Errors
2003-03-15 13:23:01 anonymous2 [Reply | View]
What does this mean (I've ssh'd into my linux box from my imac. imac is an entry in /etc/hosts):
xhost +imac
Xlib: connection to "192.168.1.20:0.0" refused by server
Xlib: No protocol specified
xhost: unable to open display "192.168.1.20:0"
Thanks for your help
-
Fink!
2003-03-15 06:06:29 bbum [Reply | View]
Once you have Apple's X11 installed, install everything else via Fink!!
Literally, installing gimp is as easy as:
fink install gimp
That's it. Fink will download and build gimp and all of the the things gimp depends on, install the result, and keep everything up to date over time!
-
If you're going to use ssh anyway...
2003-03-14 18:13:53 anonymous2 [Reply | View]
...how about moving into the late 90's and dispensing with all the xhost + nonsense and enter
ssh -X username@machinename.com
in your xterm window (with the obvious substitutions). No need to set the display on the host machine, no need to allow *everyone* on the host machine to play tricks (or worse) with your display, just nice clean encrypted fun. That is, just start using X apps on the remote machine after logging in with this command. If you're on a slow link then add in compression by using a -C flag as well. Muuuuch nicer.
Cheers,
Paul (err, "anonymous") -
If you're going to use ssh anyway...
2003-11-08 23:46:37 anonymous2 [Reply | View]
this was a huge help. I have been trying to get this working for a while and not being the biggest unix geek, I was having trouble. This made it extremely easy. Thanks for the initial post, but thanks to especially to Paul.
Ciao,
Bryan







Science Software, Games, Applications, educational software?
Everybody says 'lots of software' but where in the world can I find it please ?
Thank you!