1.1 FTP
Server Configuration Commands
Syntax
display ftp-server
View
Any view
Parameters
None
Description
Use the display ftp-server command
to display the FTP server-related settings of a switch when it operates as an
FTP server, including startup status, number of users, and so on.
You can use this command to verify FTP
server-related configurations.
Related commands: ftp server enable,
ftp timeout.
Examples
# Display the FTP server-related settings
of the switch (assuming that the switch is operating as an FTP server).
<Sysname>
display ftp-server
FTP server is running
Max user number 1
User count 0
Timeout value(in minute) 30
Table 1-1 display ftp-server command output description
|
Field
|
Description
|
|
FTP server
is running
|
The FTP
server is started. If the FTP server is not started, “% FTP server has
been stopped” will be displayed, and the three fields below will not be
displayed.
|
|
Max user
number 1
|
The FTP
server can accommodate up to one user.
|
|
User count 0
|
The current login user number is 0.
|
|
Timeout value (in minute) 30
|
The connection idle time is 30 minutes.
|
The H3C S3100
series Ethernet switch supports one user access at one time when it serves as
the FTP server.
1.1.2 display
ftp-user
Syntax
display ftp-user
View
Any view
Parameters
None
Description
Use the display ftp-user command
to display the information of the FTP users that have logged in to the switch,
including the user name, host IP address, port number, idle timeout time, and
authorized directory.
For how to create
an FTP user on an FTP server, refer to the AAA part of this manual.
Examples
# Display the information of the FTP users
that have logged in to the switch.
<Sysname> display ftp-user
UserName HostIP
Port Idle HomeDir
admin 192.168.0.152
1029 0 flash:
# If the username exceeds ten characters,
characters behind the tenth will be displayed in the second line with a
left-aligning mode. Take username username@test for example, the result
is:
<Sysname> display ftp-user
UserName HostIP
Port Idle HomeDir
administra
tor 192.168.0.152
1031 0 flash:
Table 1-2
display ftp-user command
output description
|
Field
|
Description
|
|
HostIP
|
IP address of the FTP client
|
|
Port
|
Port used when the FTP client logs in
|
|
Idle
|
Idle time of the FTP client
|
|
HomeDir
|
The initial work path configured for the
FTP user, namely, the path where the user locates after he logs in.
|
Syntax
ftp disconnect user-name
View
System view
Parameters
user-name: Name
of the user to be disconnected from the FTP server, a string of 1 to 184
characters.
Description
Use the ftp disconnect command to terminate
the connection between a specified user and the FTP server.
With an H3C S3100
series Ethernet switch acting as the FTP server, if you attempt 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.
Related commands: display ftp-user.
Examples
# Display the
current online FTP users.
<Sysname> display ftp-user
UserName HostIP
Port Idle HomeDir
admin 192.168.0.152
1029 0 flash:
# Disconnect the user named admin
from the FTP server.
<Sysname> system-view
System View: return to User View with
Ctrl+Z.
[Sysname] ftp disconnect admin
% The user connection will be
disconnected after the data transfer finished
[Sysname]
%Apr 2 01:06:14:915 2000 Sysname FTPS/5/USEROUT:-
1 -User admin(192.168.0.152) logged out
Syntax
ftp server enable
undo ftp server
View
System view
Parameters
None
Description
Use the ftp server enable command to
enable the FTP server function of the switch.
Use the undo ftp server command to
disable the FTP server function of the switch.
By default,
the FTP server function is disabled on the H3C S3100 series switch to avoid
potential security risks.
To protect unused sockets from being attacked by malicious users,
the H3C S3100 series Ethernet switch provides the following functions:
l
TCP 21 is enabled only when you start the FTP
server.
l
TCP 21 is disabled after you shut down the FTP
server.
Related commands: display ftp-server.
Examples
# Enable the FTP server.
<Sysname> system-view
System View: return to User View with
Ctrl+Z.
[Sysname] ftp server enable
% Start FTP server
Syntax
ftp timeout minutes
undo ftp timeout
View
System view
Parameters
minutes: Idle
timeout time (in minutes), in the range 1 to 35791.
Description
Use the ftp timeout command to set
the idle timeout time of an FTP client. When the idle time of the FTP client
exceeds this timeout time, the FTP server terminates the connection with the
FTP client.
Use the undo ftp timeout command to
restore the default idle timeout time.
By default, the idle timeout time is 30
minutes.
If an FTP connection between an FTP server
and an FTP client breaks down abnormally, but the FTP server cannot be aware of
this, the FTP server will keep this connection. This will occupy system
resources and affect other FTP users’ log in. You can set an idle timeout
time so that the FTP server considers an FTP connection invalid and terminates it
if no data exchange occurs on it in idle timeout time.
Examples
# Set the idle timeout time to 36 minutes.
<Sysname> system-view
System View: return to User View with
Ctrl+Z.
[Sysname] ftp timeout 36
1.2 FTP
Client Configuration Commands
l
In the examples of this section, if a command
should be executed in FTP client view, the configuration process for entering
FTP client view will be omitted to avoid repetition. For the configuration of
the command for entering FTP client view, refer to ftp.
l
When executing the FTP client configuration
commands in this section, confirm whether the corresponding access rights are
configured on the FTP server, for example, query file lists under a working
directory, read/download the specified files, create a directory/upload a file,
and rename/delete a file on the server. For the configuration of user access
rights, refer to the FTP server software description.
Syntax
ascii
View
FTP client view
Parameters
None
Description
Use the ascii command to specify
that files be transferred in ASCII mode, which is used for transferring text
files.
By default, files are transferred in ASCII
mode.
Related commands: binary.
Examples
# Specify to transfer text files in ASCII
mode.
[ftp] ascii
200 Type set to A.
Syntax
binary
View
FTP client view
Parameters
None
Description
Use the binary command to specify
that program files be transferred in binary mode, which is used for
transferring program files.
By default, files are transferred in ASCII
mode.
Related commands: ascii.
Examples
# Specify to transfer files in binary mode.
[ftp] binary
200 Type set to I.
Syntax
bye
View
FTP client view
Parameters
None
Description
Use the bye command to terminate the
control connection and data connection with the FTP server and return to user
view.
This command has the same effect as that of
the quit command.
Examples
# Terminate the connections with the remote
FTP server and return to user view.
[ftp] bye
221 Server closing.
<Sysname>
Syntax
cd path
View
FTP client view
Parameters
path: Path of
the target directory.
Description
Use the cd command to change the
working directory on the remote FTP server.
Note that you can use this command to enter
only authorized directories.
Related commands: pwd.
Examples
# Change the working directory to flash:/temp.
[ftp] cd flash:/temp
# Display the current working directory.
[ftp] pwd
257 "flash:/temp" is
current directory.
Syntax
cdup
View
FTP client view
Parameters
None
Description
Use the cdup command to exit the
current working directory and enter the parent directory. The parent directory
must be a directory that a user is authorized to access; otherwise, the command
cannot be executed.
Related commands: cd, pwd.
Examples
# Change the working directory to flash:/temp.
[ftp] cd flash:/temp
# Change the working directory to the
parent directory.
[ftp] cdup
# Display the current directory.
[ftp] pwd
257 "flash:" is current
directory.
Syntax
close
View
FTP client view
Parameters
None
Description
Use the close command to terminate
an FTP connection without quitting FTP client view.
This command has the same effect as that of
the disconnect command.
Examples
# Terminate the FTP connection without quitting
FTP client view.
[ftp] close
221 Server closing.
[ftp]
Syntax
delete remotefile
View
FTP client view
Parameters
remotefile: Name
of the file to be deleted.
Description
Use the delete command to delete a
specified remote file.
Examples
# Delete the file temp.c.
[ftp] delete temp.c
250 DELE command successful.
Syntax
dir [
filename [ localfile ] ]
View
FTP client view
Parameters
filename: Name
of the file to be queried.
localfile:
Name of the local file where the query result is to be saved.
Description
Use the dir command to query specified
files on a remote FTP server, or to display file information in the current
directory. The output information, which includes the name, size and creation
time of files, will be saved in a local file.
If you do not specify the filename
argument, the information about all the files in the current directory is
displayed.
Caution:
You can use the dir
command to display the file-related information such as file size, creation date,
and so on. To display only the names of all the files under the current
directory, use the ls command.
Related commands: pwd.
Examples
# Display the information about all the files
in the current directory on the remote FTP server.
[ftp] dir
227 Entering Passive Mode
(192,168,0,152,4,0).
125 ASCII mode data connection already
open, transfer starting for *.
-rwxrwxrwx 1 noone nogroup
377424 Apr 26 13:05 s3r01.btm
-rwxrwxrwx 1 noone nogroup
377424 Oct 10 2006 s3r01_15.btm
-rwxrwxrwx 1 noone nogroup
2833 May 11 17:58 config.cfg
-rwxrwxrwx 1 noone nogroup
225295 Apr 26 12:21 default.diag
-rwxrwxrwx 1 noone nogroup
377424 Apr 30 16:58 switch.btm
drwxrwxrwx 1 noone
nogroup 0 Apr 28 11:41 test
-rwxrwxrwx 1 noone nogroup
2145 Apr 28 13:13 test.txt
-rwxrwxrwx 1 noone nogroup
13 Apr 28 13:21 mytest.bak
-rwxrwxrwx 1 noone
nogroup 9 Apr 28 13:24 a.txt
-rwxrwxrwx 1 noone nogroup
142 Sep 10 2006 myopenssh
-rwxrwxrwx 1 noone nogroup
5292802 Apr 30 17:02 switch2.bin
-rwxrwxrwx 1 noone
nogroup 15 Apr 26 17:45 public
-rwxrwxrwx 1 noone
nogroup 15 Apr 26 17:56 temp.c
-rwxrwxrwx 1 noone nogroup
5286666 Oct 18 2006 switch5.bin
-rwxrwxrwx 1 noone nogroup
306 May 13 11:17 swithc001
226 Transfer complete.
FTP: 1025 byte(s) received in 0.019
second(s) 53.00K byte(s)/sec.
# Display information about file config.cfg
and save the information to file temp1.
[ftp] dir config.cfg temp1
227 Entering Passive Mode
(192,168,0,152,4,3).
125 ASCII mode data connection
already open, transfer starting for config.cfg.
.....226 Transfer complete.
FTP: 67 byte(s) received in 5.818
second(s) 11.00 byte(s)/sec.
Syntax
disconnect
View
FTP client view
Parameters
None
Description
Use the disconnect command to terminate
an FTP connection without quitting FTP client view.
This command has the same effect as that of
the close command.
Examples
# Terminate the FTP connection without quitting
FTP client view.
[ftp] disconnect
221 Server closing.
[ftp]
1.2.10 ftp
Syntax
ftp [ cluster
| remote-server [ port-number ] ]
View
User view
Parameters
cluster: Connects
to the configured FTP server of a cluster. For the configuration of the FTP
server of a cluster, refer to the Cluster part of this manual.
remote-server: Host name or IP address of an FTP server, a string of 1 to 20
characters.
port-number:
Port number of the FTP server, in the range 0 to 65535. The default is 21.
Description
Use the ftp command to establish a
control connection with an FTP server. If you enter a correct username and
password, you can enter FTP client view.
Examples
# Connect to the FTP server whose IP
address is 2.2.2.2.
<Sysname>
ftp 2.2.2.2
Trying ...
Press CTRL+K to abort
Connected.
220 FTP service ready.
User(none):admin
331 Password required for admin.
Password:
230 User logged in.
[ftp]
1.2.11 get
Syntax
get remotefile
[ localfile ]
View
FTP client view
Parameters
remotefile: Name
of a file to be downloaded.
localfile: File
name used when a file is downloaded and saved to the local device. If this
argument is not specified, the source file name is used when a file is saved
and downloaded to the local device.
Description
Use the get command to download a
remote file and save it as a local file.
Caution:
When using the get
command to download files from a remote FTP server, note to limit the length of
file path and file name within the following ranges:
l
A directory name should be no more than 91
characters.
l
A file name plus its local path name should be
no more than 127 characters.
l
A device name should be no more than 14
characters.
l
A file name plus its complete path name should
be no more than 142 characters.
Examples
# Download file temp.c.
[ftp] get temp.c
227 Entering Passive Mode (2,2,2,2,4,12).
125 ASCII mode data connection
already open, transfer starting for temp.c.
..226 Transfer complete.
FTP: 15 byte(s) received in 2.568
second(s) 0.00 byte(s)/sec.
Syntax
lcd
View
FTP client view
Parameters
None
Description
Use the lcd command to display the local
working directory on the FTP client. If you have logged in to the FTP server,
you cannot modify the local working directory of the FTP client; to modify the local
working directory, you need to terminate the connection with the FTP server,
quit FTP client view, execute the cd command in user view, and reconnect
to the FTP server.
Examples
# Display the local working directory on
the FTP client.
[ftp] lcd
% Local directory now flash:/temp
Syntax
ls [ remotefile
[ localfile ] ]
View
FTP client view
Parameters
remotefile:
Name of the file to be queried.
localfile:
Name of the local file where the querying result is to be saved.
Description
Use the ls command to display the
information about a specified file on an FTP server.
If you do not specify the remotefile
argument, names of all the files in the current remote directory are displayed.
Caution:
The ls command only displays file names on an FTP server. To
query other file-related information, for example, file size, creation date and
so on, use the dir command.
Related commands: pwd.
Examples
# Display the names of all the files in the
current directory on the remote FTP server.
[ftp] ls
227 Entering Passive Mode (2,2,2,2,4,4).
125 ASCII mode data connection
already open, transfer starting for *.
s3r01.btm
s3r01_15.btm
config.cfg
default.diag
test
test.txt
mytest.bak
a.txt
myopenssh
public
temp.c
swithc001
226 Transfer complete.
FTP: 200 byte(s) received in 0.145
second(s) 1.00Kbyte(s)/sec.
Syntax
mkdir pathname
View
FTP client view
Parameters
pathname: Name
of the directory to be created.
Description
Use the mkdir command to create a
directory on an FTP server.
This command is available only to the FTP
clients that are assigned the permission to create directories on FTP servers.
Related commands: dir, rmdir.
Examples
# Create the directory flash:/lanswitch
on the FTP server.
[ftp] mkdir flash:/lanswitch
257 "flash:/ lanswitch" new
directory created.
Syntax
open { ip-address
| server-name } [ port ]
View
FTP client view
Parameters
ip-address: IP
address of an FTP server.
server-name:
Host name of the FTP server, a string of 1 to 20 characters.
port: Port
number on the remote FTP server, in the range 0 to 65535. The default value is
21.
Description
Use the open command to establish a
control connection with an FTP server. If you have connected to an FTP server,
you cannot use the open command to connect to another server, and you
need to terminate the connection with the current FTP server and then execute
the open command.
Related commands: close.
Examples
# Establish a control connection with the
FTP server whose IP address is 1.1.1.1 in FTP client view.
[ftp]open 1.1.1.1
Trying ...
Press CTRL+K to abort
Connected.
220 FTP service ready.
User(none):abc
331 Password required for abc
Password:
230 User logged in.
Syntax
passive
undo passive
View
FTP client view
Parameters
None
Description
Use the passive command to set the
data transfer mode to the passive mode.
Use the undo passive command to set
the data transfer mode to the active mode.
By default, the passive mode is adopted.
The differences between the passive mode
and the active mode are:
l
When working in the active mode, an FTP client advertises
a random port Port1 to an FTP server through TCP port 21; upon receiving the advertisement,
the FTP server initiates a connection with Port1 on the client for data
transmission.
l
When working in the passive mode, an FTP client
sends a passive request to the FTP server before data transmission, the FTP
server advertises a local random port Port2 to the FTP client, and the FTP
client establishes a connection with Port2 using a local random port.
If an FTP client initiates a connection
with an FTP server through a firewall, the firewall may block the connection request
because the FTP server initiates the connection with Port1 through an external
network, and thus data transmission will be affected. Therefore, you are
recommended to set the data transmission mode of the FTP client to passive when
accessing the FTP server through a firewall.
Examples
# Set the data transfer mode to the passive
mode.
[ftp] passive
% Passive is on
Syntax
put localfile
[ remotefile ]
View
FTP client view
Parameters
localfile: Name
of a local file to be uploaded.
remotefile: File
name used after a file is uploaded and saved on an FTP server.
Description
Use the put command to upload a
local file on an FTP client to an FTP server.
If you do not specify the remotefile
argument, the local file is saved on the FTP server with its original name.
Examples
# Upload the local file named temp.c
to the FTP server.
[ftp] put temp.c
227 Entering Passive Mode (2,2,2,2,4,13).
125 ASCII mode data connection
already open, transfer starting for temp.c.
226 Transfer complete.
FTP: 15 byte(s) sent in 7.549
second(s) 1.00byte(s)/sec.
Syntax
pwd
View
FTP client view
Parameters
None
Description
Use the pwd command to display the working
directory on an FTP server.
Related commands: cd, cdup, dir,
ls.
Examples
# Display the working directory on the FTP
server.
[ftp] pwd
257 "flash:/temp" is
current directory.
Syntax
quit
View
FTP client view
Parameters
None
Description
Use the quit command to terminate
FTP control connection and FTP data connection and return to user view.
This command has the same effect as that of
the bye command.
Examples
# Terminate the FTP control connection and FTP
data connection and return to user view.
[ftp] quit
221 Server closing.
<Sysname>
Syntax
remotehelp [
protocol-command ]
View
FTP client view
Parameters
protocol-command:
FTP protocol command.
Description
Use the remotehelp command to display
the help information about an FTP protocol command.
This command works only when the FTP server
provides the help information about FTP protocol commands.
Caution:
l
This command is always valid when an H3C series Ethernet
switch operates as the FTP server.
l
If you use other FTP server software, refer to
related instructions to know whether the FTP server provides help information
about FTP protocol commands.
Examples
# Display the syntax of the user
command.
[ftp] remotehelp user
214 Syntax: USER <sp>
<username>
Syntax
rename remote-source
remote-dest
View
FTP client view
Parameters
remote-source:
Name of a file on a remote host.
remote-dest:
Destination file name.
Description
Use the rename command to rename a
file on a remote FTP server.
If the destination file name conflicts with
the name of an existing file or directory, you will fail to rename the file.
Examples
# Rename file temp.c as forever.c.
[ftp] rename temp.c forever.c
350 Enter the name to rename it to...
250 File renamed successfully
Syntax
rmdir pathname
View
FTP client view
Parameters
pathname: Name
of a directory on an FTP server.
Description
Use the rmdir command to remove a
specified directory on an FTP server.
Note that you can only use this command to
remove directories that are empty.
Examples
# Remove the directory flash:/temp1
on the FTP server. (Assume that the directory is empty.)
[ftp] rmdir flash:/temp1
200 RMD command successful.
Syntax
user username
[ password ]
View
FTP client view
Parameters
username: Username
used to log in to an FTP server.
password: Password
used to log in to an FTP server.
Description
Use the user command to log in to an
FTP server with the specified username and password.
Examples
# Log in to the FTP server using the user account
with the username tom and the password 111.
[ftp] user tom 111
331 Password required for tom.
230 User logged in.verbose
Syntax
verbose
undo verbose
View
FTP client view
Parameters
None
Description
Use the verbose command to enable the
verbose function, which displays execution information of user operations and all
FTP responses.
Use the undo verbose command to
disable the verbose function.
The verbose function is enabled by default.
Examples
# Download the file with name test1.cfg.
[ftp] get test1.cfg
227 Entering Passive Mode
(192,168,0,3,5,239)
150 "D:\FTP\test1.cfg" file
ready to send (100 bytes) in ASCII mode
....226 Transfer finished
successfully.
FTP: 100 byte(s) received in 5.109
second(s) 20.00 byte(s)/sec.
# Disable the verbose function.
[ftp] undo verbose
# Download the file with name test.cfg.
[ftp] get test.cfg
......FTP: 1740 byte(s) received in
9.367 second(s) 185.00 byte(s)/sec.
The above output indicates that if the
verbose function is disabled, only execution information of users’ operations
is obtained from the system of the switch, while the output information beginning
with three-digit numbers cannot be returned to the users.
For the description of the numbers at the
beginning of FTP output information, refer to the corresponding section in RFC
959.
Syntax
sftp server enable
undo sftp server
View
System view
Parameters
None
Description
Use the sftp server enable command
to enable the SFTP server.
Use the undo sftp server command to
disable the SFTP server.
By default, the SFTP server is disabled.
Examples
# Enable the SFTP server.
<Sysname> system-view
System View: return to User View with
Ctrl+Z.
[Sysname] sftp server enable
%Start SFTP server
Syntax
sftp timeout time-out-value
undo sftp timeout
View
System view
Parameters
time-out-value: Timeout time, in the range 1 to 35,791, in minutes. The default
value is 10.
Description
Use the sftp timeout command to set
the idle timeout time on an SFTP server.
Use the undo sftp timeout command to
restore the idle timeout time to the default value.
If the idle timeout time exceeds the
specified threshold, the system disconnects the SFTP user automatically.
Examples
# Set the idle timeout time to 500 minutes.
<Sysname> system-view
System View: return to User View with
Ctrl+Z.
[Sysname] sftp timeout 500
Syntax
bye
View
SFTP client view
Parameters