63
1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

Embed Size (px)

Citation preview

Page 1: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

1

INFO 321Server Technologies II

FTP

Material adapted from Dr. Randy Kaplan

Page 2: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

2

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

Page 3: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

3

FTP

◊ What is it?• A client server application• A pair of programs• Allows two computers to communicate

to transfer information• A well defined protocol

Page 4: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

4

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

Page 5: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

5

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

Page 6: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

6

FTP

File System

Server PI

Server DTP

User Interface

User PI

User DTP

File System

User

FTP Commands

FTP Replies

Data

Connection

Server FTP User FTP

Page 7: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

7

FTP

File System

Server PI

Server DTP

User Interface

User PI

User DTP

File System

User

FTP Commands

FTP Replies

Data

Connection

Server FTP User 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.

Page 8: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

8

FTP

File System

Server PI

Server DTP

User Interface

User PI

User DTP

File System

User

FTP Commands

FTP Replies

Data

Connection

Server FTP User 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.

Page 9: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

9

FTP

File System

Server PI

Server DTP

User Interface

User PI

User DTP

File System

User

FTP Commands

FTP Replies

Data

Connection

Server FTP User 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.

Page 10: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

10

FTP

File System

Server PI

Server DTP

User Interface

User PI

User DTP

File System

User

FTP Commands

FTP Replies

Data

Connection

Server FTP User 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.

Page 11: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

11

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

Page 12: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

12

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>

Page 13: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

Launching FTP, version 2

◊ Or you can start FTP without a hostname• C:\> ftp

◊ When you do this, the FTP prompt is displayed• ftp>

Page 14: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

14

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

Page 15: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

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

Page 16: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

16

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

Page 17: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

17

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

Page 18: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

18

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

Page 19: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

19

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

Page 20: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

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

Page 21: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

21

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)

Page 22: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

22

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

Page 23: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

23

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

Page 24: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

24

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

Page 25: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

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

Page 26: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

26

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

Page 27: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

27

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

Page 28: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

28

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

Page 29: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

29

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

Page 30: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

30

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

Page 31: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

31

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

Page 32: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

32

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

Page 33: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

33

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 = ASCIIE = EBCDICI = IMAGE (Binary transfer)L = BYTE

Page 34: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

34

Transfer Parameter Commands

◊ MODE• The modes that are used to transfer

data areStreamBlockCompressed

Page 35: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

35

FTP Protocol◊ 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

Page 36: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

36

FTP Service Commands

◊ RETR (Retrieve)• This command causes the server to

transfer a file to the computer at the other end of the connection

Page 37: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

37

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

Page 38: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

38

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

Page 39: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

39

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)

Page 40: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

40

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

Page 41: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

41

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

Page 42: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

42

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)

Page 43: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

43

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

Page 44: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

44

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

Page 45: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

45

FTP Service Commands

◊ HELP• Causes the server to send helpful

information about the implementation over the connection

Page 46: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

46

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 codeSome textHere are some examples

Page 47: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

47

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

Page 48: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

48

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.

Page 49: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

Installing FTP (Windows 2003)

Page 50: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

50

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

Page 51: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

51

Windows FTP Services

◊ A control panel will be displayed

Page 52: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

52

Windows FTP Services

Click on FTP Sites

Make sure thestatus of the site is running

Page 53: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

53

Example

FTP into your own FTP server

Page 54: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

54

Example

Log in anonymously

Page 55: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

55

Example

Identify local and remote directories

Page 56: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

56

Example

Page 57: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

57

Example

Page 58: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

58

Example

◊ Why did this problem occur?• On the server side, permissions were

not set so that the anonymous log on could have access to the directory to store the file

◊ How do you fix it?

Page 59: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

59

Example

Page 60: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

60

Try to open this file …

◊ Why?

Page 61: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

61

Example

Page 62: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

62

On the server side …

◊ Try to open the file again …

Page 63: 1 INFO 321 Server Technologies II FTP Material adapted from Dr. Randy Kaplan

FTP Summary

◊ So to use FTP effectively, need to know• Host FTP server• Login information (if not anonymous)• File location(s), both remotely and

locally• File types (binary or ascii)