Before connecting to a device as an FTP client to manage files, complete the following tasks:
The FTP protocol brings security risks. The SFTPv2, SCP, or FTPS mode is recommended.
Table 1 describes the procedure for managing files when the device functions as an FTP client.
No. | Task | Description | Remarks |
---|---|---|---|
1 | (Optional) Configure the FTP client source address | Configure the FTP client source address. To ensure communication security, the source address can be set to a source IP address or source interface. |
Perform steps 1 and 2 in sequence. After the FTP connection is established, perform steps 3 and 4 in any sequence. To disconnect from the FTP server, perform step 5. |
2 | Run FTP commands to connect to the FTP server | - |
|
3 | Run FTP commands to perform file-related operations | Run FTP commands to perform file-related operations, such as uploading and downloading files, configuring the file transfer mode, and viewing the online help about FTP commands. |
|
4 | (Optional) Change the login user | - |
|
5 | Disconnect the FTP client from the FTP server | - |
When specifying the source address in an ACL, use the address of a stable interface, for example, a loopback interface. This simplifies the ACL rule and security policy configuration. After the client source address is configured as the source or destination address in the ACL rule, IP address differences and interface status impact are shielded, and incoming and outgoing packets are filtered.
The FTP client source address must be set to the loopback interface IP address or loopback interface.
Operation | Command | Description |
---|---|---|
Enter the system view. | system-view | - |
Configure the FTP client source address. | ftp client-source { -a source-ip-address | -i interface-type interface-number } | You are advised to use the loopback interface IP address. When the FTP client source address is set to loopback interface, configure an IP address for the loopback interface for establishing FTP connections. |
Run the corresponding command in the user view or FTP client view to connect to the FTP server.
Perform the following operations based on the server IP address types.
Operation | Command | Description |
---|---|---|
Connect to the FTP server in the user view when the server uses an IPv4 address. |
ftp [ -a source-ip-address | -i interface-type interface-number ] host-ip [ port-number ] [ public-net | vpn-instance vpn-instance-name ] | Select one of them. To enter the FTP client view, run the ftp command. |
Connect to the FTP server in the FTP client view when the server uses an IPv4 address. |
ftp | |
open [ -a source-ip-address | -i interface-type interface-number ] host-ip [ port-number ] [ public-net | vpn-instance vpn-instance-name ] |
Before connecting to the FTP server, run the set net-manager vpn-instance command to set the default VPN instance. After this command is used, the FTP operation uses the default VPN instance.
The source address specified in the ftp command has a higher priority than that specified in the ftp client-source command on an IPv4 network. If you specify different source addresses in the ftp client-source and ftp commands, the source address specified in the ftp command takes effect. The source address specified in the ftp client-source command applies to all TFTP connections. The source address specified in the ftp command applies only to the current TFTP connection.
Operation | Command | Description |
---|---|---|
Connect to the FTP server in the user view when the server uses an IPv6 address. |
ftp ipv6 host-ipv6 [ port-number ] |
Select one of them. To enter the FTP client view, run the ftp command. |
Connect to the FTP server in the FTP client view when the server uses an IPv6 address. |
ftp | |
open ipv6 host-ipv6 [ port-number ] |
Users must enter the correct user name and password to connect to the server.
After connecting to the FTP server, users can run FTP commands to perform file-related operations including performing operations on directories and files, configuring the file transfer mode, and viewing the online help about FTP commands.
User rights are configured on the FTP server.
The file system limits the number of files in the root directory to 50. Creation of files in excess of this limit in the root directory may fail.
Users can perform the following operations in any sequence.
Operation | Command | Description |
---|---|---|
Change the working directory on the server. | cd remote-directory | - |
Change the current working directory to its parent directory. | cdup | - |
Display the working directory on the server. | pwd | - |
Display or change the local working directory. | lcd [ local-directory ] | The lcd command displays the local working directory on the client, and the pwd command displays the working directory on the remote server. |
Create a directory on the server. | mkdir remote-directory | The directory name can consist of letters and digits. The following special characters are not supported: < > ? \ : |
Delete a directory from the server. | rmdir remote-directory | - |
Display information about the specified directory or file on the server. | dir/ls [ remote-filename [ local-filename ] ] |
|
Delete a file from the server. | delete remote-filename | - |
Upload one or more files. | put local-filename [ remote-filename ] Or mput local-filenames |
|
Download one or more files. | get remote-filename [ local-filename ] Or mget remote-filenames |
|
Set the file transfer mode to ASCII or Binary. | ascii Or binary |
Select either of them. |
Set the data transmission mode to passive or active. | passive Or undo passive |
Select either of them. The default data transmission mode is active. |
View the online help about FTP commands. | remotehelp [ command ] | - |
Enable the system prompt function. | prompt | By default, the prompt function is disabled. |
Enable the verbose function. | verbose | After the verbose function is enabled, all FTP response messages are displayed on the FTP client. |
The current user can switch to another user in the FTP client view. The new FTP connection is the same as that established by running the ftp command.
Operation | Command | Description |
---|---|---|
Change the current user in the FTP client view. |
user user-name [ password ] | When the login user is switched to another user, the original user is disconnected from the FTP server. |
Users can run different commands in the FTP client view to disconnect the FTP client from the FTP server.
Operation | Command | Description |
---|---|---|
Disconnect the FTP client from the FTP server and return to the user view. |
bye or quit | Select one of them. |
Disconnect the FTP client from the FTP server and return to the FTP client view. |
close or disconnect |