Using SFTP Commands to Operate Files

After logging in to the SFTP server, you can manage directories and files on the server.

Context

After logging in to the SFTP server, you can perform the following operations:

  • Obtain command help information on the SFTP client.
  • Manage directories on the SFTP server.
  • Manage files on the SFTP server.

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 operation

    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 help information on the SFTP client

    Run the help [ command-name ] command.

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