640 likes | 800 Views
INFO 321 Server Technologies II. FTP. Material adapted from Dr. Randy Kaplan. FTP. FTP = File Transfer Protocol What is it? A classic client-server application Purpose: move data from computer A to computer B and vice versa. FTP. What is it? A client server application
E N D
INFO 321Server Technologies II FTP Material adapted from Dr. Randy Kaplan
FTP • FTP = File Transfer Protocol • What is it? • A classic client-server application • Purpose: move data from computer A to computer B and vice versa
FTP • What is it? • A client server application • A pair of programs • Allows two computers to communicate to transfer information • A well defined protocol
How It Works? • The FTP server is started on a system and waits for incoming requests • The user FTP program is started and the user initiates a transfer • The local FTP program interprets the command and translates the command into the required form for the server • The command is sent to the server
How It Works? • When the command is received by the FTP server it is decoded and acted upon • The result is returned to the user FTP program over the data link
FTP FTP Commands FTP Replies Data Connection User FTP Server FTP
FTP The server protocol interpreter "listens" on Port L for a connection from a user-PI and establishes a control communication connection. It receives standard FTP commands from the user-PI, sends replies, and governs the server-DTP. FTP Commands FTP Replies Data Connection User FTP Server FTP
The data transfer process, in its normal "active" state, establishes the data connection with the "listening" data port. It sets up parameters for transfer and storage, and transfers data on command from its PI. The DTP can be placed in a "passive" state to listen for, rather than initiate a connection on the data port. FTP FTP Commands FTP Replies Data Connection User FTP Server FTP
FTP The data transfer process "listens" on the data port for a connection from a server-FTP process. If two servers are transferring data between them, the user-DTP is inactive. FTP Commands FTP Replies Data Connection User FTP Server FTP
FTP The user protocol interpreter initiates the control connection from its port U to the server-FTP process, initiates FTP commands, and governs the user-DTP if that process is part of the file transfer. FTP Commands FTP Replies Data Connection User FTP Server FTP
Launching FTP, version 1 • In order to use FTP, you need to know the name of a host that has an FTP server running • Start from a terminal window or command prompt • To initiate an FTP session and go to a specific server use ftp followed by the hostname • C:\ ftp host.site.tld
Launching FTP, version 1 • After you enter this command, you will be asked for a user name and password • For anonymous login, try • User name is ‘anonymous’ • Password is ‘password’ • After you log in successfully, an FTP prompt will be displayed • ftp>
Launching FTP, version 2 • Or you can start FTP without a hostname • C:\> ftp • When you do this, the FTP prompt is displayed • ftp>
Launching FTP, version 2 Then connect to an FTP server using the open command ftp> open ftp-server-name For example,ftp> open ftp.sei.cmu.edu Log in to the server as shown on slide 12 14
FTP help! • The local help information can be obtained within FTP using the command ? or help • ftp> ? • ftp> help • ftp> help commandname • Help for the remote FTP server can be found with remotehelp • ftp> remotehelp
Exiting FTP • To log out from the current FTP server, use the disconnect or close commands • ftp> disconnect • ftp> close • To exit FTP completely, enter the command quit or bye • ftp> quit • ftp> bye
Transfer modes • When transferring a file there are two modes in which a file transfer can occur • ASCII • Transfer files in text mode (text or PDF files) • BINARY • Transfer files in binary mode (as a sequence of binary digits) • Used for transferring executables and compressed files
Transfer modes • The command to set which data transfer mode is in use is ‘type’ • ftp> type ascii • ftp> type binary • Or those types are also standalone commands • ftp> ascii • ftp> binary
Transferring Files • In order to send one file from your computer to the FTP server (upload) use the command put or send • ftp> put filename • ftp> send filename
Transferring Files • In order to transfer one file from the FTP server to your computer (download) use the command get or recv • ftp> get filename • ftp> recv filename
Multiple file transfers • Transferring multiple files • Sometimes you may wish to transfer a group of files • You can accomplish this with the mget command (download) or the mput command (upload)
Multiple file transfers • For example, if you enter the command • ftp> mget foo* • Then all of the files whose name begin with foo will be downloaded • Likewise to upload a group of files, use the command mput • ftp> mput bar* • All of the files whose name begins with bar will be uploaded to the server
Navigating in FTP • When you use these commands (get, put) they assume that the activity will take place in the current directory on the FTP server • To see what files are in the current FTP server (remote) directory you can use the command dir or ls • ftp> dir • ftp> ls
Navigating in FTP • You can change the directory on the remote FTP server by using the command cd • ftp> cd directoryname • You can change the directory on your local computer while in the FTP client by using the command lcd • ftp> lcd directoryname
Navigating in FTP • You can show the current remote directory with the pwd command • ftp> pwd • Remote directories can be created or deleted (if you have permission) with mkdir or rmdir, respectively • ftp> mkdir foldername • ftp> rmdir foldername
Shell commands • Bang (!) is used to execute a command directly by the shell (outside of FTP) • For example, if you enter • !cd downdir • The cd command will be executed by the shell • This particular result will be the same as using lcd – just to show the use of bang
FTP Server Protocol • In order to implement the FTP protocol, the server understands a set of commands issued by the FTP client • See http://ftpguide.com/index.htm
FTP Protocol • Client-Server Commands • Access Control Commands • USER – accept user name • PASS – accept password • ACCT – set account information, usually tied to USER • CWD – change working directory • CDUP – change to parent directory • SMNT – mount a different file system • REIN – reinitialize; terminate the session • QUIT – also terminates a session
Access Control Commands • USER • The USER commands identifies the user to the server • This information is required to gain access to the FTP server and the files that can be transferred
Access Control Commands • PASS • The PASS command will always follow the USER command • It specifies a password to enable a user to gain access to the FTP server
Access Control Commands • QUIT • This command terminates a session for a user • If there is no transfer then the server will close the control connection • If there is a transfer in progress, the connection will remain open until a result
FTP Protocol • Client-Server Commands • Transfer Parameter Commands • PORT – specify data port to be used • PASV – requests server to listen on a given port • TYPE – same as the previous type command • STRU – specifies the file structure code • MODE – set send/receive mode
Transfer Parameter Commands • TYPE • The TYPE command is used to specify the type of data that will be transferred during a file transfer task • The codes used in the command that specify the data type are as follows – • A = ASCII • E = EBCDIC • I = IMAGE (Binary transfer) • L = BYTE
Transfer Parameter Commands • MODE • The modes that are used to transfer data are • Stream • Block • Compressed
Client-Server Commands FTP Service Commands RETR – transfer a file STOR – accept incoming data STOU – accept unique file APPE – append existing file ALLO – allocate space REST – set restart point RNFR – rename from RNTO – rename to ABOR – abort previous cmd DELE – delete file RMD – remove directory MKD – make directory PWD – print working dir. LIST – transfer a list of files NLST – transfer list of file names SITE – set server services SYST – identify server OS STAT – send status HELP – send command list NOOP – a server ping FTP Protocol
FTP Service Commands • RETR (Retrieve) • This command causes the server to transfer a file to the computer at the other end of the connection
FTP Service Commands • STOR (Store) • Causes a file to be transferred from the computer at the other end of the connection and store on the server • If the file exists it is overwritten • If the file does not exist, it is created
FTP Service Commands • APPE (Append) • This command causes the server to append data transferred from the computer at the other end of the connection to be appended to the named file on the server • If the file exists, data is appended • If the file does not exists, the file is create
FTP Service Commands • RNFR (Rename from) • This is one of a pair of commands used to rename a file • This command specifies the file that is to be renamed • The command is immediately followed by a RNTO command (Rename to)
FTP Service Commands • RNTO (Rename to) • The second of the rename commands • Specifies the new name of the file • ABOR (Abort) • This command tells the server to stop whatever it was doing; this includes aborting the last command and any data transfer associated with that command
FTP Service Commands • DELE (Delete file) • This command causes the named file to be deleted from the server site • RMD (Remove Directory) • This command causes the specified directory to be removed from the server • The path can be absolute or relative
FTP Service Commands • MKD (Make directory) • This command creates the specified directory on the server • PWD (Print working directory) • Causes the current directory name to be returned as the result (on the server)
FTP Service Commands • LIST (List) • If the pathname specifies a directory then the files in the directory are transferred • If the pathname specifies a group of files then the files specified are transferred • If the pathname names a file then information about the file is sent
FTP Service Commands • STAT (Status) • Causes a status response to be send • If no argument is specified then the server returns general information about the status of the server • If the command is sent during a file transfer, the server will respond with the status of the transfer
FTP Service Commands • HELP • Causes the server to send helpful information about the implementation over the connection
FTP Protocol • FTP Replies • The purpose of replies from the server to the client is for the client to understand the precise status of the server after a request was made • An FTP reply consists of – • A 3 digit code • Some text • Here are some examples
Installing FTP (Server) • Most OS that make FTP available, come with the FTP server installed • For example, one of the package options during the Linux installation is FTP • On Windows, the FTP server can be loaded as an optional piece of IIS software and then started
Installing FTP (Windows) The FTP server is part of the IIS option in the Windows Components dialog. This dialog is accessible through the control panel and Add/Remove Programs.
Windows FTP Services • In order to check to see if your FTP services are running, in the Control Panel double click on Internet Information Services