port number: 21 for control connection and some port for data connection
The following commands are allowed before logging in:
- HELP prints short help about commands
- USER sends the user name to the server. Example:
USER dementiev
- PASS sends the password for the user specified by the USER command. Example:
PASS password
- STAT shows some statistics about the specified file
- MODE switches file transfer mode (binary/text). The argument is a single Telnet character code specifying
the data transfer modes described in the Section on Transmission Modes. The following codes are assigned for transfer
modes:
- S - Stream
- B - Block
- C - Compressed
The default transfer mode is Stream. Also takes parameters binary and text. Example:
MODE binary
- SYST request for the type of operating system at the server.
- QUIT logs out user from the current session
- NOOP This command does not affect any parameters or previously entered commands. It specifies no
action other than that the server send an OK reply.
- ACCT, STRU, TYPE
After logging in, the following are also allowed:
- APPE This command causes the server-DTP to accept the data transferred via the data connection and to
store the data in a file at the server site. If the file specified in the pathname exists at the server site, then
the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server
site.
- CDUP change directory to the parent directory
- CWD change directory using the argument as the destination. Example:
CWD www
- DELE This command causes the file specified in the argument to be deleted at the server site.
- LIST request for the list of all files in the current directory
- PORT The argument is a HOST-PORT specification for the data port to be used in data connection. There
are defaults for both the user and server data ports, and under normal circumstances this command and its reply are
not needed. If this command is used, the argument is the concatenation of a 32-bit internet host address and a 16-bit
TCP port address. This address information is broken into 8-bit fields and the value of each field is transmitted as
a decimal number (in character string representation). The fields are separated by commas. A port command would be:
PORT h1,h2,h3,h4,p1,p2
where h1 is the high order 8 bits of the internet host address.
- PASV This command requests the server-DTP to "listen" on a data port (which is not its default data port)
and to wait for a connection rather than initiate one upon receipt of a transfer command. The response to this
command includes the host and port address this server is listening on (in the same format as PORT command).
- PWD prints the current directory.
- RETR request for a file specified as argument. This file will be sent by the server over the data
connection. Example:
RETR index.html
- STOR This command causes the server-DTP to accept the data transferred via the data connection and to
store the data as a file at the server site. If the file specified in the pathname exists at the server site,
then its contents shall be replaced by the data being transferred.
- ALLO, MKD, NLST, RNFR, RNTO, RMD,
SITE, STOU, XCUP, XCWD, XMKD, XPWD,
XRMD, ABOR.
To emulate a typical FTP session we need to open two DOS windows and have either a small server
(which is capable on listening on a given port and printing all incoming messages on the screen) or be ready to start
the second TELNET client. Then the session may look like:
...> telnet ist.marshall.edu 21
220 ProFTPD 1.2.7 Server (ProFTPD Default Installation) [dementiev-x.marshall.edu]
user ist362
331 Password required for ist362.
pass test
230 User ist362 logged in.
port 10,102,44,119,8,0 use IP of your computer here
At this moment we need to start the server and make the server wait on the
port 2048 = 8*256+0. We also assume that the IP of the computer we are working on is 10.102.44.119
200 PORT command successful
list
150 Opening ASCII mode data connection for file list
226 Transfer complete.
pasv
227 Entering Passive Mode (10,102,44,117,130,55).
At this moment we need to start the second telnet client and connect to
IP 10.102.44.117 PORT 33335 = 130*256+55
noop
200 NOOP command successful.
retr hello.txt
150 Opening ASCII mode data connection for message.txt (147 bytes)
226 Transfer complete.
quit
221 Goodbye.
For more information read
RFC spec about FTP.