SSH (or Secure Shell) is a way of connecting to a remote computer over a network. As the name implies, the connection is secure, which means that any data transferred using the connection will remain private.
SSH can be used for various purposes in relation to the databar, which will be the focus of this article. For backgroud infomation, see the wikipedia page on SSH.
Usage
SSH is a very powerful tool, which has a broad range of possibilities:
- Remote terminal
In its most simple form, SSH is used to obtain a terminal (or shell) on a remote machine. This can be used to log in to the linux machines from home or from a windows machine, and run programs on that machine.
- File transfer
SSH provides a secure way to transfer files to/from your home directory.
- X11 forwaring
X11 is the de facto system for displaying graphics on linux and UNIX machines. With X11 forwarding it is possible to run a graphic application on a remote machine, and get the graphic interface to display on the local machine. For this to work, a so-called X server must be running on the local machine. This is explained in the article about remote linux login.
- Port forwaring
This is one of the more advanced features, which allow network connections to be forwarded through the SSH connection (which is also called tunneling). The details will not be explained in this article.
OpenSSH (Linux, UNIX, Solaris, Mac OS X, etc.)
These operating systems usually comes with a version of OpenSSH installed, which provides the command-line utilities described below. To use it you must first open a terminal window.
- ssh
The ssh command is used to obtain a terminal on a remote machine. It can be used in the following ways (everything in square brackets is optional, but never include the brackets):
- The following command will connect to the remote machine hostname and open a terminal. The current username will be used unless username@ is specified in front of the hostname:
- This command does the same as above, but instead of opening a terminal, the given command is executed. The connection is closed as soon as the command finishes:
ssh [username@]hostname command |
- If the
-X option is specified, X11 forwarding is enabled:ssh -X [username@]hostname [command] |
Example:
ssh s123456@ebar091.ebar.dtu.dk |
This will open a terminal on one of the linux servers and log in as the user
s123456.
- scp
The scp (secure copy) command is similar to the cp (copy) command, but allows you to specify which machine(s) to copy to/from. It is used like this:
- This command will copy the file filename from the local machine to the machine given by hostname. If the destination path is not specified, the file will be placed in the home directory:
scp filename [username@]hostname:[destination/path] |
- This command will copy the file path/to/filename from the remote machine given by hostname to the current directory on the local machine. If you want to copy the file to another location, change the dot to the path of the destination directory:
scp [username@]hostname:path/to/filename . |
- Same as the first example, but an entire directory is copied:
scp -r directory [username@]hostname:[destination/path] |
- This will copy a file (filename) from the remote machine hostname1 to the other remote machine hostname2, possibly using a different account on each machine:
scp [username1@]hostname1:filename [username2@]hostname2:[destination/path] |
A more thorough explanation of how OpenSSH is used can be found in the SSH Tutorial.
Windows Clients
Several SSH clients are available for windows. The most useful are:
- PuTTY
PuTTY is a very powerful SSH client for Windows. Amongst others, it provides a terminal client (putty.exe) and a file transfer utility (pscp.exe). The former is described in the PuTTY article, while the latter is used in the same way as the scp program described above.
Both programs (and other related utilities) can be downloaded from the PuTTY homepage:
Putty is available on the Windows installations in the E-Bar.
- WinSCP
WinSCP is a graphical substitute for the scp program, which allows you to drag and drop files to/form a remote server.
The WinSCP program is free and can be downloaded from this page:
WinSCP is available on the Windows installations in the E-Bar.