This guide will help you setup a SSH (Secure SHell) client to connect to the NICE linux servers. These clients only give you a simple command line terminal interface to the server. This guide will also help you set up the X windows system (the graphical user interface system for Linux) so you get a good user interface.
To log in to a NICE Linux server, you make an SSH connection to nice.harvard.edu.1 SSH is a secure communication protocol. Mac OS X and Linux machines normally include an implementation of SSH that can be used from the command line. In a terminal window on your personal machine, you issue an SSH command that connects to the remote server. After you supply your password, it leaves you at a command prompt from the server machine. So SSH effectively turns your local terminal into a remote terminal of the server, until you choose to log out of the server.
Windows users usually obtain SSH by installing a terminal emulator such as SecureCRT or PuTTY. You launch one of these applications for the express purpose of creating a command window that's securely connected to the remote server. But the net effect is the same as in the Mac OS X/Linux case: you end up with a command-line interface to the remote server, not a GUI.
So how can you benefit from the GUI features of an application like Emacs when you're connecting remotely from your own PC?
It turns out that most implementations of SSH provide support for the open-source window system called X, which is the native window system of Linux and UNIX. While it has much in common with other window systems, X is unusual in that its implementation is distributed. That means that every time an X-based program like Emacs changes the user's display or receives input from the keyboard, it uses the Internet to transmit the information. As a result, the computer controlling the display, mouse, and keyboard can be different from the computer running the X-based application (such as Emacs), as long as they are both on the Internet and they both support X.
When you use a Linux workstation in the Science Center, you won't normally take advantage of the distributed nature of its window system, because your GUI-based applications will be running on the same machine that's managing the display, mouse, and keyboard. But if your personal computer supports X, it can handle the graphical user interface for applications that are actually running on a remote machine that you have connected to via SSH. So you can make an SSH connection to one of the NICE servers, start Emacs on that server, and it will create a new X window on your own machine. Apart form its border decorations, that window looks just like it would if you were at a Linux workstation in the Science Center. And you can control it just as conveniently with your mouse and keyboard.
We're about to explain how to make your computer support X windows in this way. But first, a bit of lore and jargon.
By default, forwarding of X connections through SSH is not turned on. To be sure that it's enabled when you need it, you can change your personal SSH configuration. Here's a series of commands to do that when you're logged into fas.harvard.edu or nice.harvard.edu:
mkdir -pThe mkdir above makes sure that you have a .ssh directory in your home directory. Then the chmod command makes sure that no one but you can read or write that directory. The touch command makes sure that a file called config exists under/.ssh
chmod go-rwx/.ssh
cd/.ssh
touch config
echo "ForwardX11 yes" » config
ForwardX11 yesOf course, if you'd rather just use an editor to make sure that
No matter how you make your SSH connection to nice.harvard.edu, there's a simple way
to tell whether it's capable of supporting X windows. Type the command
echo $DISPLAY at the shell prompt from the
remote machine. The response should look like localhost:
.0,
where
is a two- or three-digit number. SSH should have set
DISPLAY automatically to this value. When an X client like
Emacs uses this setting of DISPLAY to contact its X server,
the messages it sends are piped through the secure SSH tunnel to
your terminal.
If the DISPLAY value is something else, then your current shell
initialization may be setting DISPLAY explicitly, rather than
allowing it to be set by SSH. Use an editor to inspect the files
/.login and
/.cshrc, and eliminate
commands that set DISPLAY.
If you have Linux on your own machine, it's easy to configure for
connecting to the NICE servers because X windows are native to Linux
and because SSH configured in
/.ssh/config on your PC
almost exactly as you have it in your FAS home directory. However,
instead of adding just one line to
/.ssh/config,
make sure that it contains the following two lines:2
ForwardX11 yesNow, in a terminal window running under X on your own machine, run the command
ForwardX11Trusted yes
ssh username@nice.harvard.eduwhere username is your FAS user name.3When you have a prompt from one of the NICE servers (whose names look like ice
$DISPLAY. If the DISPLAY
environment variable is defined and looks like localhost:
Now suppose that you have a terminal window connected to a nice.harvard.edu server,
and that your $DISPLAY variable is correctly set. To start
Emacs, putting it into the background so that you can keep using
your terminal, type4
emacs &
$DISPLAY variable is set), but
you want to use Emacs in non-X mode anyway, add -nw as a
command-line option:
emacs -nw
In non-X mode, you'll have to experiment to find out which keys work as they do under X and which don't. It varies from terminal emulator to terminal emulator. There's a way to get everything done, but it may sometimes be inconvenient. The ``GNU Emacs Reference Card'' can be used as a survival aid. Except for the strictly mouse-related commands, it usually shows at least one key sequence per command that will work on almost any terminal.
When configured properly, the SecureCRT and PuTTY terminal emulators
provide surprisingly good windows in which to run Emacs.
But, Emacs is much nicer to use under X.
Waiting for background jobs to be terminated...and then waits until all background processes have finished.