186
◾
Linux with Operating System Concepts
a copy remote copy command that allows you to copy files
from the remote computer to
your host computer.
Although the r-utilities require that you have an account on the remote computer for
authentication purposes, all interactions are handled in normal text, just as with telnet. Thus,
any communication using either telnet or an r-utility is insecure. In place of telnet is
ssh
, the
secure shell program. The ssh program uses public key encryption (refer back to Section 5.5).
The local computer uses the public key, which is known to any or all computers. The public
key encrypts messages into a code. Only the remote computer has the private key.
The ssh command is followed by the IP address or alias of the remote computer you
want to log into. By default, ssh will attempt to log you in using your current account
name. To override this, prepend the IP address/alias with username@, as in
ssh
foxr@10.11.12.13
to log into the computer at 10.11.12.13 with the account name foxr.
Another old technology is FTP.
FTP is file transfer protocol, and it was developed in
1971 for the ARPAnet (an early incarnation of the Internet). With FTP, a user makes a con-
nection with a remote computer to transfer files. Notice how this differs from telnet and
ssh that in essence opens a terminal window to the remote computer. With FTP, only files
are moved between remote and host computers. Files can be sent to the remote computer,
often referred to as uploading, and files can be sent from the remote computer to the local
computer, often referred to as downloading. To access the remote computer in this way,
you must either have an account or you must log in as an anonymous user. If the remote
computer permits
anonymous
logins, this provides the user access only to the public area.
In Linux, this is often a top-level directory called /pub.
The initial
FTP command is like telnet,
ftp
address
where
address
is the IP address
or IP alias of the remote computer. You are then asked to log in. To log in anonymously, type
anonymous for your user name and your email address for your password. Although the
password is not used for authentication, it is captured in a log file so that others can see who
has logged in anonymously (and so it is not truly anonymous!) Once connected, you have an
ftp
>
prompt. From here, there are
numerous commands available, as shown in Table 5.3.
Today, there are many GUI-based FTP programs. These typically have a drag-and-drop
feel so that you can copy individual or multiple files very easily. You can change local and
remote directories, view contents of local and remote directories, create and delete directo-
ries, and so forth. FileZilla is one of the most popular GUI-based FTP programs available
in Linux.
FTP, like telnet, is insecure. This not only results in making FTP transfers (including
any passwords sent) open to view by IP spoofers and packet sniffers,
but also leaves open
security holes on FTP servers. There are more secure forms of file transfer now available.
These include secure FTP (not to be confused with SFTP) that uses various forms of secu-
rity to protect the information being transmitted, FTPS that is FTP extended to include
encryption, SFTP and SCP (secure copy), which use ssh to transfer files, and FTP over SSH,
which requires that the user first logs in using ssh and then accesses the remote computer
using FTP. Two drawbacks of FTP over SSH are that the remote computer must be able to
handle both FTP and ssh and that the user must have an account on the remote machine
because ssh does not permit anonymous logins.
Linux Applications
◾
187
FTP has largely become obsolete in the face of the newer HTTP and HTTPS protocols.
HTTP and HTTPS are the protocols used in support of the World Wide Web. Commands
to transfer files using these protocols can be entered at the
command line or generated
by software such as a web browser or a search engine spider (or crawler). HTTP has just
a few commands, the most significant are GET (to request a file), HEAD (to request just
the header of a file without the file’s contents), OPTIONS (to see which commands the
web server will respond to), PUT (to upload a file), and POST (to upload data to a server,
such as a post to a discussion board). HTTPS is one of the secure forms of HTTP that
involves public key encryption and the transfer of a certificate to ensure that the website
is legitimate.
Both the
wget
and
nc
programs allow the user to transmit HTTP requests to servers
from the command line. The wget program is a noninteractive and text-based form of access.
The user enters the URL and the
server responds with the file, which is stored locally to the
hard disk rather than displayed in a web browser. In essence, wget serves the same purpose as
FTP except that the remote computer is a web server and there is no log-in process.
The wget program supports a recursive download so that the command can be used to
retrieve not only a target file by URL but also all the files that the target URL has links to,
recursively. If not done cautiously, this could result in a download of an entire website! The
recursive version of the command is useful for a web spider that attempts to accumulate
all pages of a web server. There are GUI-based interactive versions of wget available. Below
are
three examples of wget, the first downloads a single file, the second uses a wildcard
(the extension.jpg) to download a number of jpg files, and the third performs a recursive
download.
TABLE 5.3
FTP Commands
Do'stlaringiz bilan baham: