Using SFTP Commands to Operate Files

You can manage directories and files of the SSH server through the SFTP client and view help for all SFTP commands on the SFTP client.

Context

After logging in to the SSH server from the SFTP client, you can perform the following operations on the SFTP client:

  • Create and delete directories of the SSH server; view the current working directory; view files in a directory and the list of sub-directories.
  • Rename, delete, upload, and download files.
  • View command help on the SFTP client.

Perform the following steps on the router that functions as an SSH client:

Procedure

  1. Run system-view

    The system view is displayed.

  2. Run either of the following commands:

    For IPv4:

    Run the sftp [ -a source-ip-address ] [ -force-receive-pubkey ] host-ip-address [ port-number ] [ [ prefer_kex prefer_kex ] | [ prefer_ctos_cipher prefer_ctos_cipher ] | [ prefer_stoc_cipher prefer_stoc_cipher ] | [ prefer_ctos_hmac prefer_ctos_hmac ] | [ prefer_stoc_hmac prefer_stoc_hmac ] | [ prefer_ctos_compress zlib ] | [ prefer_stoc_compress zlib ] | [ public-net | -vpn-instance vpn-instance-name ] | [ -ki interval ] | [ -kc count ] | [ identity-key identity-key-type ] | [ user-identity-key user-key ] ] * command to log in to the SSH server using an IPv4 address through SFTP and enter the SFTP client view.

    For IPv6:

    Run the sftp ipv6 [ -force-receive-pubkey ] [ -a source-ipv6-address ] host-ipv6-address [ [ [ -vpn-instance vpn-instance-name ] | public-net ] | [ -oi { interface-name | interface-type interface-number } ] [ port-number ] | [ prefer_kex { prefer_kex } ] | [ prefer_ctos_cipher prefer_ctos_cipher ] | [ prefer_stoc_cipher prefer_stoc_cipher ] | [ prefer_ctos_hmac prefer_ctos_hmac ] | [ prefer_stoc_hmac prefer_stoc_hmac ] | [ prefer_ctos_compress zlib ] | [ prefer_stoc_compress zlib ] | [ -ki interval ] | [ -kc count ] | [ identity-key identity-key-type ] | [ user-identity-key user-key ] ]* command to log in to the SSH server using an IPv6 address through SFTP and enter the SFTP client view.

  3. Perform one or more operations described in Table 1 as needed.

    Table 1 File operations

    File Operation

    Description

    Managing directories

    Changing the current working directory

    Run the cd [ path ] command.

    Changing the current working directory to the parent directory

    Run the cdup command.

    Displaying the current working directory

    Run the pwd command.

    Displaying files in a directory and the list of sub-directories

    Run the dir [ remote-filename [ local-filename ] ] command.

    Deleting directories on the server

    Run the rmdir directory-name command.

    Creating a directory on the server

    Run the mkdir path command.

    Managing files

    Renaming a file on the server

    Run the rename old-name new-name command.

    Downloading files from a remote server

    Run the get remote-filename [ local-filename ] command.

    Uploading files to a remote server

    Run the put local-filename [ remote-filename ] command.

    Deleting files from the server

    Run the remove path or delete file command.

    Displaying command helps on the SFTP client

    Run the help [ command-name ] command.

  4. Run commit

    The configuration is committed.

Follow-up Procedure

There is a limit to the maximum number of SFTP clients that can connect to the SFTP server at the same time. Therefore, after performing the desired operations on the SFTP server, disconnect the SFTP client from the SFTP server so that other users can access the SFTP server.

You can run the bye, exit, or quit command in the SFTP client view to disconnect the SFTP client from the SFTP server.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >