ssh -X
is not the same as startx
. SSH is a program used for connecting to another computer with a shell. X is the graphical display program.
SSH can be used as an interactive command shell and can also be used to forward ports. ssh -X
forwards the local X display's port to the remote computer and usually sets up the remote environment so that if you start a graphical program remotely it will display locally. Normally you wouldn't run an entire desktop such as KDE in this way; you'd just run one or two programs.
startx
is a command used to start an X server locally when you are logged into the console of the server, that is, the physical keyboard and screen. Most people avoid using startx because it can be a security risk if you leave your computer unattended. Starting X creates a second virtual console (the first was the text console you logged into), and someone can switch back to the text console (CTRL-ALT-F1 or something similar) and hit CTRL-C to kill your X console, and then they are logged-in as you in your text console. But if you don't leave the computer unattended it may be okay to use occaisionally.
The normal way to run a full-fledged graphical desktop on a system is to use a login manager such as XDM (or GDM/KDM for Gnome/KDE). On RedHat and friends this is usually achieved by switching to runlevel 5. From a command prompt you can type telinit 5
to switch temporarily, or edit /etc/inittab
to set the default runlevel (typical choices are 3 - no X - and 5 - with X).
As for starting GNOME and KDE, by default when you run startx
CentOS should run one of them (probably GNOME). There are configuration files you can change to override the default.
If you want to access a full desktop environment remotely, you need to look into setting XDM up for remote access, or using VNC or some other remote desktop protocol. For a full desktop I'd recommend something like VNC because that way your session stays open when you are disconnected. But you should consider that typical X or VNC over the network is not encrypted and you may want to set up an ssh port forwarding tunnel to encrypt the data. If you just run one or two apps with ssh -X
then it will be encrypted already.
What kind of client computer are you using to connect to this server? Both ssh -X
and XDM require a local X display, whereas something like VNC does not.
Edit:
If you have an X server on your local computer, you can use ssh -X to connect to the CentOS machine and start a program, such as firefox, which will display on the macbook. This link has information about using X on MacOS X. By default Apple's X server shows each application in its own window, which is perfect for running a few apps using the ssh -X
method. However, if you wanted to run an entire full-screen graphical environment, you'd need to have your local X server connect to the CentOS's XDM; you'll then see (on your macbook) a screen similar to what you'd see if you were logged into the CentOS's local console. This basically uses your Macbook as a dumb terminal: only the display, keyboard, and mouse are used locally. The programs execute on the CentOS machine. Unfortunately I can't help you set up a dumb terminal since it's been about 10 years since I last did it.
If you don't have an X server on your local computer, you can set up something like VNC (see here for more remote-desktop products), so that the X session is running on the server, on its physical display, but can be accessed remotely from a computer with the appropriate remote-desktop client. For example, KDE has a desktop-sharing application which exposes the running KDE session over VNC. You could log into the CentOS server (via XDM or text-console + startx), start the desktop-sharing, and then connect to that with a VNC client on the Macbook.
X11 itself is not a very secure protocol.
You should use X11 forwarding with SSH. This will encrypt the connection and provide better security.
First, enable the ssh daemon on your Solaris system. Solaris 10 should come with SSH preinstalled. See if the process is running with ps -ef | grep ssh
On your MacBook Pro, run Terminal.app, then use ssh -X xclient.subdom2.example.com
to connect to the Solaris system and start an X11 tunnel. You can launch X11 programs from the Solaris system and they will start on the MacBook under X11 automatically.
To do X11 forwarding on your Windows system, you'll need two programs. Xming which is a lightweight X11 server, originally from Cygwin, and puTTY, an SSH terminal program for Windows. You'll need to enable X11 forwarding in puTTY.
For better performance, you'll want to enable compression. This is done with the ssh program on OS X using the -c
option (ssh -cX
), or in puTTY on the SSH Panel (section 4.18.3 enable compression).
Best Answer
If I recall correctly ssh -X maps the X server to the target machine and then routes connections through the channel created by SSH to the terminal (i.e. your machine). The "X server" is the software that draws the window for the "X clients" which are the programs that use those windows.
Yes, startx starts the X server. But on Mac OS X you start the X server by starting X11.app in Utilities.
You wouldn't really want that unless you are trying to restart the X server on the computer you SSH into. But that wouldn't have anything to do with your connection to that computer or the programs you want to run via that connection.
Not sure I understand the question. What window manager the remote server runs is inconsequential for your connection. Window managers run on X servers (they are special X clients) and the X server on your Mac and the X server on the remote machine are two separate beasts.
VNC is a different solution for the problem of displaying GUI apps remotely. You can combine the two but I recommend you try to understand them separately.
Let Paul be your Mac and Peter be the (Linux) machine you connect to:
Paul: startx (or rather, start X11.app and use the terminal window it creates for the following)
Paul: xhost +Peter
Paul: ssh -X Peter
Peter: xlogo& (this should now display on Paul's screen, if not, continue)
Peter: export DISPLAY=Paul:0
Peter: xlogo& (this should now display on Paul's screen)