30-FTP-SFTP-TFTP Operation

Download


Chapter 1  FTP and SFTP Configuration

1.1  Introduction to FTP and SFTP

1.1.1  Introduction to FTP

FTP (file transfer protocol) is commonly used in IP-based networks to transmit files. Before World Wide Web comes into being, files are transferred through command lines, and the most popular application is FTP. At present, although E-mail and Web are the usual methods for file transmission, FTP still has its strongholds.

As an application layer protocol, FTP is used for file transfer between remote server and local client. FTP uses TCP ports 20 and 21 for data transfer and control command transfer respectively. Basic FTP operations are described in RFC 959.

FTP-based file transmission is performed in the following two modes:

l           Binary mode for program file transfer

l           ASCII mode for text file transfer

An H3C S3100 series Ethernet switch can act as an FTP client or the FTP server in FTP-employed data transmission:

Table 1-1 Roles that an H3C S3100 series Ethernet switch acts as in FTP

Item

Description

Remarks

FTP server

An Ethernet switch can operate as an FTP server to provide file transmission services for FTP clients. You can log in to a switch operating as an FTP server by running an FTP client program on your PC to access files on the FTP server.

The prerequisite is that a route exists between the switch and the PC.

FTP client

In this case, you need to establish a connection between your PC and the switch through a terminal emulation program or Telnet, execute the ftp X.X.X.X command on your PC. (X.X.X.X is the IP address of an FTP server or a host name), and enter your user name and password in turn. A switch can operate as an FTP client, through which you can access files on the FTP server.

 

1.1.2  Introduction to SFTP

Secure FTP (SFTP) is established based on an SSH2 connection. It allows a remote user to log in to a switch to manage and transmit files, providing a securer guarantee for data transmission. In addition, since the switch can be used as a client, you can log in to remote devices to transfer files securely.

1.2  FTP Configuration

Table 1-2 FTP configuration tasks

Item

Configuration task

Description

FTP Configuration: A Switch Operating as an FTP Server

Creating an FTP user

Required

Enabling an FTP server

Required

Configuring connection idle time

Optional

Configuring the banner for an FTP server

Optional

Displaying FTP server information

Optional

FTP Configuration: A Switch Operating as an FTP Client

Basic configurations on an FTP client

 

1.2.1  FTP Configuration: A Switch Operating as an FTP Server

I. Creating an FTP user

Configure the user name and password for the FTP user and set the service type to FTP. To use FTP services, a user must provide a user name and password for being authenticated by the FTP server. Only users that pass the authentication have access to the FTP server.

Table 1-3 Create an FTP user

Operation

Command

Description

Enter system view

system-view

Add a local user and enter local user view

local-user user-name

Required

By default, no local user is configured.

Configure a password for the specified user

password { simple | cipher } password

Optional

By default, no password is configured.

Configure the service type as FTP

service-type ftp

Required

By default, no service is configured.

 

II. Enabling an FTP server

Table 1-4 Enable an FTP server

Operation

Command

Description

Enter system view

system-view

Enable the FTP server function

ftp server enable

Required

Disabled by default.

 

&  Note:

l      Only one user can access an H3C S3100 series Ethernet switch at a given time when the latter operates as an FTP server.

l      Operating as an FTP server, an H3C S3100 series Ethernet switch cannot receive a file whose size exceeds its storage space. The clients that attempt to upload such a file will be disconnected with the FTP server due to lack of storage space on the FTP server.

l      You cannot access an H3C S3100 series switch operating as an FTP server through Microsoft Internet Explorer. To do so, use other client software.

 

&  Note:

To protect unused sockets against attacks, the S3100 Ethernet switch provides the following functions:

l      TCP 21 is enabled only when you start the FTP server.

l      TCP 21 is disabled when you shut down the FTP server.

 

III. Configuring connection idle time

After the idle time is configured, if the server does not receive service requests from a client within a specified time period, it terminates the connection with the client, thus preventing a user from occupying the connection for a long time without performing any operation.

Table 1-5 Configure connection idle time

Operation

Command

Description

Enter system view

system-view

Configure the connection idle time for the FTP server

ftp timeout minutes

Optional

30 minutes by default

 

IV. Disconnecting a specified user

On the FTP server, you can disconnect a specified user from the FTP server to secure the network.

Table 1-6 Disconnect a specified user

Operation

Command

Description

Enter system view

system-view

On the FTP server, disconnect a specified user from the FTP server

ftp disconnect user-name

Required

 

&  Note:

With an H3C S3100 series Ethernet switch acting as the FTP server, if a network administrator attempts to disconnect a user that is uploading/downloading data to/from the FTP server the S3100 Ethernet switch will disconnect the user after the data transmission is completed.

 

V. Configuring the banner for an FTP server

Displaying a banner: With a banner configured on the FTP server, when you access the FTP server through FTP, the configured banner is displayed on the FTP client. Banner falls into the following two types:

l           Login banner: After the connection between an FTP client and an FTP server is established, the FTP server outputs the configured login banner to the FTP client terminal.

Figure 1-1 Process of displaying a login banner

l           Shell banner: After the connection between an FTP client and an FTP server is established and correct user name and password are provided, the FTP server outputs the configured shell banner to the FTP client terminal.

Figure 1-2 Process of displaying a shell banner

Table 1-7 Configure the banner display for an FTP server

Operation

Command

Description

Enter system view

system-view

Configure a login banner

header login text

Required

Use either command or both.

By default, no banner is configured.

Configure a shell banner

header shell text

 

&  Note:

For details about the header command, refer to the Login part of the manual.

 

VI. Displaying FTP server information

After the above configurations, you can execute the display commands in any view to display the running status of the FTP server and verify your configurations.

Table 1-8 Display FTP server information

Operation

Command

Description

Display the information about FTP server configurations on a switch

display ftp-server

Available in any view

Display the login FTP client on an FTP server

display ftp-user

 

1.2.2  FTP Configuration: A Switch Operating as an FTP Client

I. Basic configurations on an FTP client

By default a switch can operate as an FTP client  In this case you can connect the switch to the FTP server to perform FTP-related operations (such as creating/removing a directory) by executing commands on the switch. Table 1-9 lists the operations that can be performed on an FTP client.

Table 1-9 Basic configurations on an FTP client

Operation

Command

Description

Enter FTP client view

ftp [ cluster | remote-server [ port-number ] ]

Specify to transfer files in ASCII characters

ascii

Use either command

By default, files are transferred in ASCII characters.

Specify to transfer files in binary streams

binary

Set the data transfer mode to passive

passive

Optional

passive by default.

Change the working directory on the remote FTP server

cd pathname

Optional

Change the working directory to be the parent directory

cdup

Get the local working path on the FTP client

lcd

Display the working directory on the FTP server

pwd

Create a directory on the remote FTP server

mkdir pathname

Remove a directory on the remote FTP server

rmdir pathname

Delete a specified file

delete remotefile

Query a specified file on the FTP server

dir [ remotefile ] [ localfile ]

Optional

If no file name is specified, all the files in the current directory are displayed.

The difference between these two commands is that the dir command can display the file name, directory as well as file attributes; while the Is command can display only the file name and directory.

ls [ remotefile ] [ localfile ]

Download a remote file from the FTP server

get remotefile [ localfile ]

Optional

Upload a local file to the remote FTP server

put localfile [ remotefile ]

Rename a file on the remote server

rename remote-source remote-dest

 Log in with the specified user name and password

user username [ password ]

Connect to a remote FTP server

open { ip-address | server-name } [ port ]

Terminate the current FTP connection without exiting FTP client view

disconnect

close

Terminate the current FTP connection and return to user view

quit

bye

Display the online help about a specified command concerning FTP

remotehelp [ protocol-command ]

Enable the verbose function

verbose

Optional

Enabled by default

 

1.2.3  Configuration Example: A Switch Operating as an FTP Server

I. Network requirements

A switch operates as an FTP server and a remote PC as an FTP client. The application switch.bin of the switch is stored on the PC. Upload the application to the remote switch through FTP and use the boot boot-loader command to specify switch.bin as the application for next startup. Reboot the switch to upgrade the switch application and download the configuration file config.cfg from the switch, thus to back up the configuration file.

l           Create a user account on the FTP server with the user name “switch” and password “hello”.

l           The IP addresses 1.1.1.1 for a VLAN interface on the switch and 2.2.2.2 for the PC have been configured. Ensure that a route exists between the switch and the PC.

II. Network diagram

Figure 1-3 Network diagram for FTP configurations: a switch operating as an FTP server

III. Configuration procedure

1)         Configure Switch A (the FTP server)

# Log in to the switch and enable the FTP server function on the switch. Configure the user name and password used to access FTP services, and specify the service type as FTP (You can log in to a switch through the Console port or by telnetting the switch. See the “Login” module for detailed information.)

# Configure the FTP user name as “switch”, the password as “hello”, and the service type as FTP.

<Sysname>

<Sysname> system-view

[Sysname] ftp server enable

[Sysname] local-user switch

[Sysname-luser-switch] password simple hello

[Sysname-luser-switch] service-type ftp

2)         Configure the PC (FTP client)

Run an FTP client application on the PC to connect to the FTP server. Upload the application named switch.bin to the root directory of the Flash memory of the FTP server, and download the configuration file named config.cfg from the FTP server. The following takes the command line window tool provided by Windows as an example:

# Enter the command line window and switch to the directory where the file switch.bin is located. In this example it is in the root directory of C:\.

C:\>

# Access the Ethernet switch through FTP. Input the user name “switch” and password “hello” to log in and enter FTP view.

C:\> ftp 1.1.1.1

Connected to 1.1.1.1.

220 FTP service ready.

User (1.1.1.1:(none)): switch

331 Password required for switch.

Password:

230 User logged in.

ftp>

# Upload the switch.bin file.

ftp> put switch.bin

200 Port command okay.

150 Opening ASCII mode data connection for switch.bin.

226 Transfer complete.

ftp: 75980 bytes received in 5.55 seconds 13.70Kbytes/sec.

# Download the config.cfg file.

ftp> get config.cfg

200 Port command okay.

150 Opening ASCII mode data connection for config.cfg.

226 Transfer complete.

ftp: 3980 bytes received in 8.277 seconds 0.48Kbytes/sec.

This example uses the command line window tool provided by Windows. When you log in to the FTP server through another FTP client, refer to the corresponding instructions for operation description.

 

  Caution:

l      If available space on the Flash memory of the switch is not enough to hold the file to be uploaded, you need to delete files not in use from the Flash memory to make room for the file, and then upload the file again. The files in use cannot be deleted. If you have to delete the files in use to make room for the file to be uploaded, you can only delete/download them through the Boot ROM menu.

l      H3C series switch is not shipped with FTP client application software. You need to purchase and install it by yourself.

 

3)         Configure Switch A (FTP server)

# After uploading the application, use the boot boot-loader command to specify the uploaded file (switch.bin) to be the startup file used when the switch starts the next time, and restart the switch. Thus the switch application is upgraded.

<Sysname> boot boot-loader switch.bin

<Sysname> reboot

 

&  Note:

For information about the boot boot-loader command and how to specify the startup file for a switch, refer to the System Maintenance and Debugging part of this manual.

 

1.2.4  FTP Banner Display Configuration Example

I. Network requirements

Configure the Ethernet switch as an FTP server and the remote PC as an FTP client. After a connection between the FTP client and the FTP server is established and login succeeds, the banner is displayed on the FTP client.

l           An FTP user named “switch” and the password “hello” have been configured on the FTP server.

l            The IP addresses 1.1.1.1 for a VLAN interface on the switch and 2.2.2.2 for the PC have been configured. Ensure that a route exists between the switch and the PC.

l           Configure the login banner of the switch as “login banner appears” and the shell banner as “shell banner appears”.

II. Network diagram

Figure 1-4 Network diagram for FTP banner display configuration

III. Configuration procedure

1)         Configure the switch (FTP server)

# Configure the login banner of the switch as “login banner appears” and the shell banner as “shell banner appears”. For detailed configuration of other network requirements, see section 1.2.3  Configuration Example: A Switch Operating as an FTP Server.

<Sysname> system-view

[Sysname] header login %login banner appears%

[Sysname] header shell %shell banner appears%

2)         Configure the PC (FTP client)

# Access the Ethernet switch through FTP. Enter the user name “switch“ and the password “hello” to log in to the switch, and then enter FTP view. Login banner appears after FTP connection is established. Shell banner appears after the user passes the authentication.

C:\> ftp 1.1.1.1

Connected to 1.1.1.1.

220-login banner appears

220 FTP service ready.

User (1.1.1.1:(none)): switch

331 Password required for switch.

Password:

230-shell banner appears

230 User logged in.

ftp>

1.2.5  FTP Configuration: A Switch Operating as an FTP Client

I. Network requirements

A switch operates as an FTP client and a remote PC as an FTP server. The switch application named switch.bin is stored on the PC. Download it to the switch through FTP and use the boot boot-loader command to specify switch.bin as the application for next startup. Reboot the switch to upgrade the switch application, and then upload the switch configuration file named config.cfg to the “switch” directory of the PC to back up the configuration file.

l           Create a user account on the FTP server with the user name “switch” and password “hello”, and grant the user “switch” read and write permissions for the directory named “Switch” on the PC.

l           Configure the IP address 1.1.1.1 for a VLAN interface on the switch, and 2.2.2.2 for the PC. Ensure a route exists between the switch and the PC.

II. Network diagram

Figure 1-5 Network diagram for FTP configurations: a switch operating as an FTP client

III. Configuration procedure

1)         Configure the PC (FTP server)

Perform FTP server–related configurations on the PC, that is, create a user account on the FTP server with user name “switch” and password “hello”. (For detailed configuration, refer to the configuration instruction relevant to the FTP server software.)

2)         Configure the switch (FTP client)

# Log in to the switch. (You can log in to a switch through the Console port or by telnetting the switch. See the “Login” module for detailed information.)

 

  Caution:

If available space on the Flash memory of the switch is not enough to hold the file to be uploaded, you need to delete files not in use from the Flash memory to make room for the file, and then upload the file again.  The files in use cannot be deleted. If you have to delete the files in use to make room for the file to be uploaded, you can only delete/download them through the Boot ROM menu.

 

# Connect to the FTP server using the ftp command in user view. You need to provide the IP address of the FTP server, the user name and the password as well to enter FTP view.

<Sysname> ftp 2.2.2.2

Trying ...

Press CTRL+K to abort

Connected.

220 FTP service ready.

User(none):switch

331 Password required for switch.

Password:

230 User logged in.

[ftp]

# Enter the authorized directory on the FTP server.

[ftp] cd switch

# Execute the put command to upload the configuration file named config.cfg to the FTP server.

[ftp] put config.cfg

# Execute the get command to download the file named switch.bin to the Flash memory of the switch.

[ftp] get switch.bin

# Execute the quit command to terminate the FTP connection and return to user view.

[ftp] quit

<Sysname>

# After downloading the file, use the boot boot-loader command to specify the downloaded file (switch.bin) to be the application for next startup, and then restart the switch. Thus the switch application is upgraded.

<Sysname> boot boot-loader switch.bin

<Sysname> reboot

 

&  Note:

For information about the boot boot-loader command and how to specify the startup file for a switch, refer to the “System Maintenance and Debugging” module of this manual.

 

1.3  SFTP Configuration

Table 1-10 SFTP configuration tasks

Item

Configuration task

Description

SFTP Configuration: A Switch Operating as an SFTP Server

Enabling an SFTP server

Required

Configuring connection idle time

Optional

Supported SFTP client software

SFTP Configuration: A Switch Operating as an SFTP Client

Basic configurations on an SFTP client

 

1.3.1  SFTP Configuration: A Switch Operating as an SFTP Server

I. Enabling an SFTP server

Before enabling an SFTP server, you need to enable the SSH server function and specify the service type of the SSH user as SFTP or all. For details, see the SSH server configuration part of SSH Operation Manual of this manual.

Table 1-11 Enable an SFTP server

Operation

Command

Description

Enter system view

system-view

Enable an SFTP server

sftp server enable

Required

Disabled by default

 

II. Configuring connection idle time

After the idle time is configured, if the server does not receive service requests from a client within a specified time period, it terminates the connection with the client, thus preventing a user from occupying the connection for a long time without performing any operation.

Table 1-12 Configure connection idle time

Operation

Command

Description

Enter system view

system-view

Configure the connection idle time for the SFTP server