12-SFTP Commands
Chapters Download (92.74 KB)
Syntax
sftp server enable
undo sftp server enable
View
System view
Default Level
2: System level
Parameters
None
Description
Use the sftp server enable command to enable SFTP server.
Use the undo sftp server enable command to disable SFTP server.
By default, SFTP server is disabled.
Examples
# Enable SFTP server.
<Sysname> system-view
[Sysname] sftp server enable
Syntax
sftp server idle-timeout time-out-value
undo sftp server idle-timeout
View
System view
Default Level
2: System level
Parameters
time-out-value: Timeout period in minutes. It ranges from 1 to 35,791.
Description
Use the sftp server idle-timeout command to set the idle timeout period for SFTP user connections.
Use the undo sftp server idle-timeout command to restore the default.
By default, the idle timeout period is 10 minutes.
Examples
# Set the idle timeout period for SFTP user connections to 500 minutes.
<Sysname> system-view
[Sysname] sftp server idle-timeout 500
Syntax
bye
View
SFTP client view
Default Level
3: Manage level
Parameters
None
Description
Use the bye command to terminate the connection with an SFTP server and return to user view.
This command functions as the exit and quit commands.
Examples
# Terminate the connection with the SFTP server.
sftp-client> bye
Bye
Connection closed.
<Sysname>
Syntax
cd [ remote-path ]
View
SFTP client view
Default Level
3: Manage level
Parameters
remote-path: Name of a directory on the server.
Description
Use the cd command to change the working directory on an SFTP server. With the argument not specified, the command displays the current working directory.
l You can use the cd .. command to return to the parent directory.
l You can use the cd / command to return to the root directory of the SFTP server.
Examples
# Change the working directory to new1.
sftp-client> cd new1
Current Directory is:
/new1
Syntax
cdup
View
SFTP client view
Default Level
3: Manage level
Parameters
None
Description
Use the cdup command to return to the parent directory.
Examples
# From the current working directory /new1, return to the parent directory.
sftp-client> cdup
Current Directory is:
/
Syntax
delete remote-file&<1-10>
View
SFTP client view
Default Level
3: Manage level
Parameters
remote-file&<1-10>: Names of the files to be deleted from the SFTP server. &<1-10> means that you can provide up to 10 filenames, which are separated by space.
Description
Use the delete command to delete one or more files from a server.
This command functions as the remove command.
Examples
# Delete file temp.c from the server.
sftp-client> delete temp.c
The following files will be deleted:
/temp.c
Are you sure to delete it? [Y/N]:y
This operation may take a long time. Please wait...
File successfully Removed
Syntax
dir [ -a | -l ] [ remote-path ]
View
SFTP client view
Default Level
3: Manage level
Parameters
-a: Displays the names of the files and sub-directories under the specified directory.
-l: Displays the detailed information of the files and sub-directories under the specified directory in the form of a list.
remote-path: Name of the directory to be queried.
Description
Use the dir command to display information about the files and sub-directories under a specified directory.
With the –a and –l keyword not specified, the command displays detailed information of the files and sub-directories under the specified directory in the form of a list.
With the remote-path not specified, the command displays information about the files and sub-directories of the current working directory.
This command functions as the ls command.
Examples
# Display detailed information about the files and sub-directories under the current working directory in the form of a list.
sftp-client> dir
-rwxrwxrwx 1 noone nogroup 1759 Aug 23 06:52 config.cfg
-rwxrwxrwx 1 noone nogroup 225 Aug 24 08:01 pubkey2
-rwxrwxrwx 1 noone nogroup 283 Aug 24 07:39 pubkey1
-rwxrwxrwx 1 noone nogroup 225 Sep 28 08:28 pub1
drwxrwxrwx 1 noone nogroup 0 Sep 28 08:24 new1
drwxrwxrwx 1 noone nogroup 0 Sep 28 08:18 new2
-rwxrwxrwx 1 noone nogroup 225 Sep 28 08:30 pub2
Syntax
display sftp client source
View
Any view
Default Level
1: Monitor level
Parameters
None
Description
Use the display sftp client source command to display the source IP address or source interface currently set for the SFTP client.
If neither source IP address nor source interface is specified for the SFTP client, the system displays such a message: “Neither source IP address nor source interface was specified for the SFTP client.”
Related commands: sftp client source.
Examples
# Display the source IP address of the SFTP client.
<Sysname> display sftp client source
The source IP address you specified is 192.168.0.1
Syntax
exit
View
SFTP client view
Default Level
3: Manage level
Parameters
None
Description
Use the exit command to terminate the connection with an SFTP server and return to user view.
This command functions as the bye and quit commands.
Examples
# Terminate the connection with the SFTP server.
sftp-client> exit
Bye
Connection closed.
<Sysname>
Syntax
get remote-file [ local-file ]
View
SFTP client view
Default Level
3: Manage level
Parameters
remote-file: Name of a file on the SFTP server.
local-file: Name for the local file.
Description
Use the get command to download a file from an SFTP server and save it locally.
If you do not specify the local-file argument, the file will be saved locally with the same name as that on the SFTP server.
Examples
# Download file temp1.c and save it as temp.c locally.
sftp-client> get temp1.c temp.c
Remote file:/temp1.c ---> Local file: temp.c
Downloading file successfully ended
Syntax
help [ all | command-name ]
View
SFTP client view
Default Level
3: Manage level
Parameters
all: Displays a list of all commands.
command-name: Name of a command.
Description
Use the help command to display a list of all commands or the help information of an SFTP client command.
With neither the argument nor the keyword specified, the command displays a list of all commands.
Examples
# Display the help information of the get command.
sftp-client> help get
get remote-path [local-path] Download file.Default local-path is the same
as remote-path
Syntax
ls [ -a | -l ] [ remote-path ]
View
SFTP client view
Default Level
3: Manage level
Parameters
-a: Displays the names of the files and sub-directories under the specified directory.
-l: Displays the detailed information of the files and sub-directories under the specified directory in the form of a list.
remote-path: Name of the directory to be queried.
Description
Use the ls command to display information about the files and sub-directories under a specified directory.
With the –a and –l keyword not specified, the command displays detailed information of the files and sub-directories under the specified directory in the form of a list.
With the remote-path not specified, the command displays information about the files and sub-directories of the current working directory.
This command functions as the dir command.
Examples
# Display detailed information about the files and sub-directories under the current working directory in the form of a list.
sftp-client> ls
-rwxrwxrwx 1 noone nogroup 1759 Aug 23 06:52 config.cfg
-rwxrwxrwx 1 noone nogroup 225 Aug 24 08:01 pubkey2
-rwxrwxrwx 1 noone nogroup 283 Aug 24 07:39 pubkey1
-rwxrwxrwx 1 noone nogroup 225 Sep 28 08:28 pub1
drwxrwxrwx 1 noone nogroup 0 Sep 28 08:24 new1
drwxrwxrwx 1 noone nogroup 0 Sep 28 08:18 new2
-rwxrwxrwx 1 noone nogroup 225 Sep 28 08:30 pub2
Syntax
mkdir remote-path
View
SFTP client view
Default Level
3: Manage level
Parameters
remote-path: Name for the directory to be created on the SFTP server.
Description
Use the mkdir command to create a directory on an SFTP server.
Examples
# Create a directory named test on the SFTP server.
sftp-client> mkdir test
New directory created
Syntax
put local-file [ remote-file ]
View
SFTP client view
Default Level
3: Manage level
Parameters
local-file: Name of a local file.
remote-file: Name for the file on an SFTP server.
Description
Use the put command to upload a local file to an SFTP server.
If you do not specify the remote-file argument, the file will be saved remotely with the same name as the local one.
Examples
# Upload local file temp.c to the SFTP server and save it as temp1.c.
sftp-client> put temp.c temp1.c
Local file:temp.c ---> Remote file: /temp1.c
Uploading file successfully ended
Syntax
pwd
View
SFTP client view
Default Level
3: Manage level
Parameters
None
Description
Use the pwd command to display the current working directory on an SFTP server.
Examples
# Display the current working directory on the SFTP server.
sftp-client> pwd
/
Syntax
quit
View
SFTP client view
Default Level
3: Manage level
Parameters
None
Description
Use the quit command to terminate the connection with an SFTP server and return to user view.
This command functions as the bye and exit commands.
Examples
# Terminate the connection with the SFTP server.
sftp-client> quit
Bye
Connection closed.
<Sysname>
Syntax
remove remote-file&<1-10>
View
SFTP client view
Default Level
3: Manage level
Parameters
remote-file&<1-10>: Names of the files to be deleted from the SFTP server. &<1-10> means that you can provide up to 10 filenames, which are separated by space.
Description
Use the remove command to delete one or more files from an SFTP server.
This command functions as the delete command.
Examples
# Delete file temp.c from the server.
sftp-client> remove temp.c
The following files will be deleted:
/temp.c
Are you sure to delete it? [Y/N]:y
This operation may take a long time.Please wait...
File successfully Removed
Syntax
rename oldname newname
View
SFTP client view
Default Level
3: Manage level
Parameters
oldname: Original name of the file or directory.
newname: New name for the file or directory.
Description
Use the rename command to change the name of a specified file or directory on an SFTP server.
Examples
# Change the name of a file on the SFTP server from temp1.c to temp2.c.
sftp-client> rename temp1.c temp2.c
File successfully renamed
Syntax
rmdir remote-path&<1-10>
View
SFTP client view
Default Level
3: Manage level
Parameters
remote-path&<1-10>: Name of the directory on the SFTP server. &<1-10> means that you can provide up to 10 directory names that are separated by space.
Description
Use the rmdir command to delete one or more directories from an SFTP server.
Examples
# On the SFTP server, delete directory temp1 in the current directory.
sftp-client> rmdir temp1
Directory successfully removed
Syntax
sftp server [ port-number ] [ vpn-instance vpn-instance-name ] [ identity-key { dsa | rsa } | prefer-ctos-cipher { 3des | aes128 | des } | prefer-ctos-hmac { md5 | md5-96 | sha1 | sha1-96 } | prefer-kex { dh-group-exchange | dh-group1 | dh-group14 } | prefer-stoc-cipher { 3des | aes128 | des } | prefer-stoc-hmac { md5 | md5-96 | sha1 | sha1-96 } ] *
View
User view
Default Level
3: Manage level
Parameters
server: IPv4 address or host name of the server, a case-insensitive string of 1 to 20 characters.
port-number: Port number of the server, in the range 0 to 65535. The default is 22.
vpn-instance vpn-instance-name: Specifies the VPN instance to which the server belongs. vpn-instance-name is a case-sensitive string of 1 to 31 characters.
identity-key: Specifies the algorithm for publickey authentication, either dsa or rsa. The default is dsa.
prefer-ctos-cipher: Preferred encryption algorithm from client to server, defaulted to aes128.
l 3des: Encryption algorithm 3des-cbc.
l aes128: Encryption algorithm aes128-cbc.
l des: Encryption algorithm des-cbc.
prefer-ctos-hmac: Preferred HMAC algorithm from client to server, defaulted to sha1-96.
l md5: HMAC algorithm hmac-md5.
l md5-96: HMAC algorithm hmac-md5-96.
l sha1: HMAC algorithm hmac-sha1.
l sha1-96: HMAC algorithm hmac-sha1-96.
prefer-kex: Preferred key exchange algorithm, defaulted to dh-group-exchange.
l dh-group-exchange: Key exchange algorithm diffie-hellman-group-exchange-sha1.
l dh-group1: Key exchange algorithm diffie-hellman-group1-sha1.
l dh-group14: Key exchange algorithm diffie-hellman-group14-sha1.
prefer-stoc-cipher: Preferred encryption algorithm from server to client, defaulted to aes128.
prefer-stoc-hmac: Preferred HMAC algorithm from server to client, defaulted to sha1-96.
Description
Use the sftp command to establish a connection to an IPv4 SFTP server and enter SFTP client view.
Note that when the client’s authentication method is publickey, the client needs to get the local private key for validation. As the publickey authentication includes RSA and DSA algorithms, you must specify an algorithm (by using the identity-key keyword) in order to get the correct data for the local private key. By default, the encryption algorithm is DSA.
Examples
# Connect to SFTP server 10.1.1.2, using the following algorithms:
l Preferred key exchange algorithm: dh-group1.
l Preferred encryption algorithm from server to client: aes128.
l Preferred HMAC algorithm from client to server: md5.
l Preferred HMAC algorithm from server to client: sha1-96.
<Sysname> sftp 10.1.1.2 prefer-kex dh-group1 prefer-stoc-cipher aes128 prefer-ctos-hmac md5 prefer-stoc-hmac sha1-96
Input Username:
Syntax
sftp client ipv6 source { ipv6 ipv6-address | interface interface-type interface-number }
undo sftp client ipv6 source
View
System view
Default Level
3: Manage level
Parameters
ipv6 ipv6-address: Specifies a source IPv6 address.
interface interface-type interface-number: Specifies a source interface by its type and number.
Description
Use the sftp client ipv6 source command to specify the source IPv6 address or source interface for an SFTP client.
Use the undo sftp client ipv6 source command to remove the configuration.
By default, the client uses the interface address specified by the route of the device to access the SFTP server.
Related commands: display sftp client source.
Examples
# Specify the source IPv6 address of the SFTP client as 2:2::2:2.
<Sysname> system-view
[Sysname] sftp client ipv6 source ipv6 2:2::2:2
Syntax
sftp client source { ip ip-address | interface interface-type interface-number }
undo sftp client source
View
System view
Default Level
3: Manage level
Parameters
ip ip-address: Specifies a source IPv4 address.
interface interface-type interface-number: Specifies a source interface by its type and number.
Description
Use the sftp client source command to specify the source IPv4 address or interface of an SFTP client.
Use the undo sftp source-interface command to remove the configuration.
By default, a client uses the IP address of the interface specified by the route to access the SFTP server.
Related commands: display sftp client source.
Examples
# Specify the source IP address of the SFTP client as 192.168.0.1.
<Sysname> system-view
[Sysname] sftp client source ip 192.168.0.1
Syntax
sftp ipv6 server [ port-number ] [ identity-key { dsa | rsa } | prefer-ctos-cipher { aes128 | des } | prefer-ctos-hmac { md5 | md5-96 | sha1 | sha1-96 } | prefer-kex { dh-group-exchange | dh-group1 | dh-group14 } | prefer-stoc-cipher { aes128 | des } | prefer-stoc-hmac { md5 | md5-96 | sha1 | sha1-96 } ] *
View
User view
Default Level
3: Manage level
Parameters
server: IPv6 address or host name of the server, a case-insensitive string of 1 to 46 characters.
port-number: Port number of the server, in the range 0 to 65535. The default is 22.
identity-key: Specifies the algorithm for publickey authentication, either dsa or rsa. The default is dsa.
prefer-ctos-cipher: Preferred encryption algorithm from client to server, defaulted to aes128.
l 3des: Encryption algorithm 3des-cbc.
l aes128: Encryption algorithm aes128-cbc.
l des: Encryption algorithm des-cbc.
prefer-ctos-hmac: Preferred HMAC algorithm from client to server, defaulted to sha1-96.
l md5: HMAC algorithm hmac-md5.
l md5-96: HMAC algorithm hmac-md5-96.
l sha1: HMAC algorithm hmac-sha1.
l sha1-96: HMAC algorithm hmac-sha1-96.
prefer-kex: Preferred key exchange algorithm, defaulted to dh-group-exchange.
l dh-group-exchange: Key exchange algorithm diffie-hellman-group-exchange-sha1.
l dh-group1: Key exchange algorithm diffie-hellman-group1-sha1.
l dh-group14: Key exchange algorithm diffie-hellman-group14-sha1.
prefer-stoc-cipher: Preferred encryption algorithm from server to client, defaulted to aes128.
prefer-stoc-hmac: Preferred HMAC algorithm from server to client, defaulted to sha1-96.
Description
Use the sftp ipv6 command to establish a connection to an IPv6 SFTP server and enter SFTP client view.
Note that when the client’s authentication method is publickey, the client needs to get the local private key for validation. As the publickey authentication includes RSA and DSA algorithms, you must specify an algorithm (by using the identity-key keyword) in order to get the correct data for the local private key. By default, the encryption algorithm is DSA.
Examples
# Connect to server 2:5::8:9, using the following algorithms:
l Preferred key exchange algorithm: dh-group1.
l Preferred encryption algorithm from server to client: aes128.
l Preferred HMAC algorithm from client to server: md5.
l Preferred HMAC algorithm from server to client: sha1-96.
<Sysname> sftp ipv6 2:5::8:9 prefer-kex dh-group1 prefer-stoc-cipher aes128 prefer-ctos-hmac md5 prefer-stoc-hmac sha1-96
Input Username: