SSH——Running GUI Programs via SSH
SSH can be used tunnel graphical applications over a network as well as text-based ones. GUIs are more complicated than text, and refore harder set up and more likely to require extra software.
Check Your SSH Server SettingsBy default, Ubuntu's SSH server has everything need enabled. If have disabled features for security reasons, you might not be able to start GUI programs. To make sure, look in your /etc/ssh/sshd_config for this line:
AllowTcpForwarding No
This disables forwarding of Internet connections over SSH. You should delete this line if you want to use VNC for GUI programs (discussed below).
Next, look for this line:
X11Forwarding yes
This enables Unix-style GUI forwarding over SSH. If you don't see it, open the file in your favourite text editor and add that line.
You will need superuser privileges to save changes to /etc/ssh/sshd_config.
Single ApplicationsIf you are logging in from a Unix-like operating system, you can forward single applications over SSH very easily, because all Unix-like systems share a common graphics layer called X11. This even works under Mac OS X, although you will need to install and start the before using SSH.
To forward single applications, connect to your system using the command-line, but add the -X option to forward X11 connections:
ssh -X joe@laptop
Once the connection is made, type the name of your GUI program on the command-line:
firefox &
Your program will start as normal, although you might find it's a little slower than it would be if it were running locally. The trailing & means that the program should run in "background mode", so you can start typing new commands in straight away, rather than waiting for your program to finish.
If you only want to run a single command, you can log in like this:
ssh -f -T -X joe@laptop firefox
That will run Firefox, then exit when it finishes. See for information about -f and -T.
If you start an application and it complains that it cannot find the display, try installing the xauth package from the Main repository (). Xauth is installed by default with desktop installations but not server installations.
If you suspect that programs are running slowly because of a lack of bandwith, you can turn SSH compression on with the -C option:
ssh -fTXC joe@laptop firefox
Using
-fTXChere is identical to
-f -T -X -C.
- 最新评论