Telnet Telnet allows you to login, albeit insecurely, to any remote machine running a telnet server. Telnet will allow you to open a shell and use simple command line unix tools on the remote machine.
In this example, imagine you are telnetting to a machine named “fred”. Sometimes you may have to use the fully qualified name of the machine (e.g., Fred.arizona.edu) or use Fred’s IP address: 22.214.171.124. You will need to login to Fred and provide your password.
FtpFTP is the file transfer protocol. Like telnet, it is an old insecure protocol. It is being replaced by scp, but is still in use on some machines. FTP can operate in text or binary mode, with the prompt on or off. It can get files from the remote machine or put files on the remote machine, either singly or in large batches. By default, ftp operates in text mode with the prompt on, we usually alter these defaults at the beginning of a new ftp session. FTP will allow you to cd between directories, but it may have trouble with listing, copying, moving and removing files and directories. Telnet is better suited for these general unix commands.
To start an ftp connection from a unix machine:
As with telnet above, you may sometimes need to use Fred’s fully qualified domain name or IP address and you will need to login.
ftp>bin (this will tell ftp to transfer the data in binary mode instead of text mode. You will typically be tranferring image data, so you want to be in binary mode. In fact, it never hurts to be in binary mode, even if you are transferring text files.)
ftp>prompt (this will tell ftp not to ask you about transferring each individual file. If you are about to move dozens of files, you will want to type “prompt”).
Local and Remote Machines (Understanding get and put)
In the simplest scenario, I sit down at one machine (e.g., “Mary”) and I ftp to another machine (e.g., “Fred”):
In this case, Mary is my local machine and Fred is the remote machine.
However, it can be much more complicated. Suppose I’m sitting at home at my PC and I telnet to Mary. After logging in to Mary, I ftp Fred. Again, Mary is the local machine (the machine where I started the ftp session) and Fred is the remote machine.
Let’s make it even worse. I telnet from home to Mary. Then I telnet from Mary to Fred, and then ftp from Fred to Mary. Now Fred is the local machine and Mary is the remote machine.
To understand when to use “get” or “mget” versus “put” or “mput”, you must understand these abstract concepts of the remote and local machines. However, it does get confusing, so if you try “put” and get back a message like “no such file or directory”, then try “get” instead.
Let’s go back to the simplest case, I ftp from Mary to Fred. Mary is my local machine.
- I should use “put” or “mput” to transfer files from Mary (local) to Fred (remote).
- I should use “get” or “mget” to transfer files from Fred (remote) to Mary (local).
You should start your ftp session in the directory on the local machine where files to transfer reside or where you intend to place them.
You can use the “cd” command to move around on the remote machine once you have ftp’d there
In this example “put” is used to copy a single specified file from the local machine (specifically, from the directory you started the ftp session in) to the remote machine (the directory you are in on the remote machine).
“mput” [multiple puts] tells ftp to copy all files that meet the criterion, in this case, all files beginning with a capital P, from the current directory on the local machine to the current directory on the remote machine.
Copy a single file “bird.jpg” from the current directory on the remote machine to the current directory on the local machine.
Copy all “*.jpg” files from the current directory on the remote machine to the current directory on the local machine.
Exits the ftp session
Tells you more about the options and flags available with ftp.
SSHssh=secure shell (secure telnet)
To use these programs, they must be installed on both communicating machines. For a machine to receive an ssh or scp request (i.e., for it to answer when you request a connection to it) it must be running an ssh server (sshd). Typically only unix machines will run ssh servers. If you have trouble connecting to a machine with ssh, you should check to see if it is running an ssh server (or daemon):
>ps -ef | sshd
Same user on local and remote machines
The commands you are most likely to need:
ssh machinename (where the name of the machine or IP address is substituted for the term “machinename”), e.g.,
ssh assumes you want to be the same user on the machine you are sshing TO
as you are on the machine you are coming FROM. This can be annoying.
Different user on local and remote machines
If you want to login as a different user, use the following scheme:
ssh -l username machinename
>ssh -l joe buddy
>ssh -l joe buddy.psych.arizona.edu
(-l = “login as”)
You will be asked for the password.
SCPsame user on local and remote machines
scp=secure copy (secure binary mode ftp)
Unix: You can use scp at the command line whether or not have used ssh to connect to another machine.
Windows PC: If you are using the university ssh and scp on a Windows PC, then you have a separate scp program as well as being able to use scp at the command line once you have connected with ssh.
SCP move files to or from your current location. It always uses binary mode. You can work as either the current user on the starting machine or a different user. It always asks for the user’s password. Here are some examples in which I move the file bird.jpg from one place to another. The first three examples assume you are the same user on the local and remote machines. The last example shows you how to login as someone else on the remote machine:
Put a file on a remote machine:
>scp bird.jpg buddy:/data/joe/
Get a file from a remote machine:
>scp buddy:/data/joe/bird.jpg . (the “.” means “here”)
>scp buddy:/data/joe/bird.jpg /home/fred/
(does the same thing, but just substitutes the path for “.”)
You can scp -r so that an entire directory can be copied at a time:
>scp -r e12345 buddy:/data/joe
different user on local and remote machines
Log in as someone other than who you are locally, then copy a file from your current directory to a directory (/data/fred/) on the remote machine:
>scp bird.jpg joe@buddy:/data/fred
(you will be asked for joe’s password)
Copy a file (bird.jpg) from a directory (/data/fred/) on a remote machine (buddy) where you will login as someone else (joe) to here (.)
>scp joe@buddy:/data/fred/bird.jpg .