Remote Login

You can easily log in to a remote Unix machine, provided that you have an account there.

telnet

The telnet command takes the name or IP address of the remote machine and tries to start a login session:

(~) 105% telnet formaggio.cshl.org
Trying 142.48.7.41...
Connected to formaggio.cshl.org.
Escape character is '^]'.

Linux 2.2.10 (formaggio.cshl.org) (pts/4)
login: lstein
Password: ********
Linux 2.2.10.
You have new mail.

"Calvin Coolidge was the greatest man who ever came out of Plymouth
Corner, Vermont."
		-- Clarence Darrow

(formaggio ~) 51% logout
Connection closed by foreign host.

The problem with telnet is that some full-screen programs won't work quite right, and it is horribly insecure. Your username and password are sent across the network without encryption. For this reason, many organizations forbid telnet access.

Secure Shell

ssh works like telnet, but it encrypts the connection so that your username and password can't be sniffed. It also allows you to run graphical (X Windows) applications remotely.

ssh will assume that the username on the remote machine is the same as it is on the local machine, unless you tell it otherwise by giving it a -l remote username command-line option:

(~) 108% ssh -l fred formaggio.cshl.org
Password: ********
Linux 2.2.10.
You have new mail.

I have yet to see any problem, however complicated, which, when looked
at in the right way, did not become still more complicated.
		-- Poul Anderson
(formaggio ~) 51% 

An alternative syntax is:

(~) 108% ssh fred@formaggio.cshl.org

You may even set up ssh so that you do not need to provide a password to log into the remote machine. See the manual pages for ssh and ssh-keygen for details.

Secure Copy

The scp command allows you to copy files from one machine to another. Both machines must have ssh installed and running.

Copy the local file zhmapper.tar.gz into my home directory on formaggio:
(~) 108% scp zhmapper.tar.gz formaggio.cshl.org:

Copy the local file zhmapper.tar.gz into my home directory on formaggio, and rename it "myfile.tar.gz": (~) 109% scp zhmapper.tar.gz formaggio.cshl.org:myfile.tar.gz
Copy the local file zhmapper.tar.gz into files/save/ on formaggio: (~) 110% scp zhmapper.tar.gz formaggio.cshl.org:files/save/
Copy the remote file inbox from formaggio to the current directory on the local machine (remember that "." means current directory): (~) 110% scp formaggio.cshl.org:inbox .
Copy the remote file inbox from formaggio to the current directory on the local machine using "fred" as the login name on formaggio: (~) 110% scp fred@formaggio.cshl.org:inbox .
Copy the remote file inbox between the remote machines formaggio and gouda: (~) 110% scp formaggio.cshl.org:inbox gouda.cshl.org:
Recursively copy the contents of files/save from formaggio to /usr/tmp on the current machine: (~) 110% scp -r formaggio.cshl.org:/files/save /usr/tmp

ftp

FTP is a simple file transfer program. You probably have a nice graphical version installed on your Windows machine. The Unix version is very command-line oriented. The basic commands are:

cd directory name
Change directory on the remote machine (as in the shell).
ls
List the contents of a directory.
get filename
get a file from the remote machine to the local one
put filename
put a file from the local machine to the remote one
quit
goodbye!
(~) 58% ftp formaggio.cshl.org
Connected to formaggio.cshl.org.
220 formaggio FTP server (Version wu-2.4.2-academ[BETA-15](1) Thu Jun 24 21:14:35 EDT 1999) ready.
Name (formaggio:lstein): lstein
331 Password required for lstein.
Password: ********
230 User lstein logged in.
ftp> cd projects
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 704
drwxr-xr-x  22 lstein   lstein       1024 Aug 18 16:07 .
drwxr-xr-x  34 lstein   lstein       5120 Sep  5 23:29 ..
drwxr-xr-x   7 lstein   lstein       1024 Jan  4  1999 Ace-browser
drwxrwxr-x   3 lstein   lstein       1024 Jun 23 09:55 Pts
drwxrwxr-x   2 lstein   lstein       1024 Aug 19 12:30 PubMed
drwxrwxr-x   4 lstein   lstein       1024 Aug  4 22:17 SNPdb
drwxrwxr-x   6 lstein   lstein       1024 Aug  3 11:13 Tie-DBI
drwxr-xr-x  11 lstein   lstein       1024 Apr 20  1998 rhmap
drwxr-xr-x   3 lstein   lstein       1024 Jan 21  1999 sbox
-rw-r--r--   1 lstein   lstein      23539 Jan 21  1999 sbox-1.00.tgz
226 Transfer complete.
ftp> get sbox-1.00.tgz
200 PORT command successful.
150 Opening ASCII mode data connection for sbox-1.00.tgz (23539 bytes).
226 Transfer complete.
23634 bytes received in 0.0776 secs (3e+02 Kbytes/sec)
ftp> quit
221 Goodbye.

Like telnet, ftp passes your username and password over the network in the clear. Nowadays FTP is only used for "anonymous" file transfer from public FTP servers.

ncftp

ncftp is a nicer version of ftp that supports command-line editing, shortcuts and full-screen file listings. It works just like FTP. It is installed by default in most Linux distributions, but not usually in other Unix distributions.


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Thu Oct 9 20:02:54 EDT 2003