To start the secure FTP (SFTP) client, use the sftp command.
sftp [
username
@
host
:
remote-filename
] source-filename dest-filename [source-interface type interface-path-id] [vrf vrf-name]
Syntax Description
username
|
(Optional) Name of the user performing the file transfer. The at symbol (@) following the username is required.
|
hostname:remote-filenam e
|
(Optional) Name of the Secure Shell File Transfer Protocol (SFTP) server. The colon (:) following the hostname is required.
|
source-filename
|
SFTP source, including the path.
|
dest-filename
|
SFTP destination, including the path.
|
source-interface
|
(Optional) Specifies the source IP address of a selected interface for all outgoing SSH connections.
|
type
|
Interface type. For more information, use the question mark (? ) online help function.
|
interface-path-id
|
Physical interface or virtual interface.
Note
|
Use the show
interfaces command in EXEC modeXR EXEC mode to see a list of all interfaces currently configured on the router.
|
For more information about the syntax for the router, use the question mark (? ) online help function.
|
vrf
vrf-name
|
Specifies the name of the VRF associated with the source interface.
|
Command Default
If no username argument is provided, the login name on the router is used. If no hostname argument is provided, the file is considered local.
Command Modes
EXEC modeXR EXEC mode
Command History
Release
|
Modification
|
Release 7.0.12
|
This command was introduced.
|
Usage Guidelines
SFTP provides for the secure (and authenticated) copying of files between a router and a remote host. Like the copy command, the sftp command can be invoked only in EXEC modeXR EXEC mode.
If a username is not provided, the login name on the router is used as the default. If a host name is not provided, the file
is considered local.
If the source interface is specified in the sftp command, the sftp interface takes precedence over the interface specified in the ssh client source-interface command.
When the file destination is a local path, all of the source files should be on remote hosts, and vice versa.
When multiple source files exist, the destination should be a preexisting directory. Otherwise, the destination can be either
a directory name or destination filename. The file source cannot be a directory name.
If you download files from different remote hosts, that is, the source points to different remote hosts, the SFTP client spawns
SSH instances for each host, which may result in multiple prompts for user authentication.
From Cisco IOS XR Software
Release 7.10.1 and later, you can use public-key based user authentication for Cisco IOS XR routers configured as SSH clients as well. This
feature thereby allows you to use password-less authentication for secure file transfer and copy operations using SFTP and
SCP protocols.
Task ID
Task ID
|
Operations
|
crypto
|
execute
|
basic-services
|
execute
|
Examples
In the following example, user abc is downloading the file ssh.diff from the SFTP server ena-view1 to disk0:
RP/0/RP0RSP0/CPU0:router#sftp abc@ena-view1:ssh.diff disk0
In the following example, user abc is uploading multiple files from disk 0:/sam_* to /users/abc/ on a remote SFTP server called ena-view1:
RP/0/RP0RSP0/CPU0:router# sftp disk0:/sam_* abc@ena-view1:/users/abc/
In the following example, user admin is downloading the file run from disk0a: to disk0:/v6copy on a local SFTP server using an IPv6 address:
RP/0/RP0RSP0/CPU0:router#sftp admin@[2:2:2::2]:disk0a:/run disk0:/V6copy
Connecting to 2:2:2::2...
Password:
disk0a:/run
Transferred 308413 Bytes
308413 bytes copied in 0 sec (338172)bytes/sec
RP/0/RP0RSP0/CPU0:router#dir disk0:/V6copy
Directory of disk0:
70144 -rwx 308413 Sun Oct 16 23:06:52 2011 V6copy
2102657024 bytes total (1537638400 bytes free)
In the following example, user admin is uploading the file v6copy from disk0: to disk0a:/v6back on a local SFTP server using an IPv6 address:
RP/0/RP0RSP0/CPU0:router#sftp disk0:/V6copy admin@[2:2:2::2]:disk0a:/v6back
Connecting to 2:2:2::2...
Password:
/disk0:/V6copy
Transferred 308413 Bytes
308413 bytes copied in 0 sec (421329)bytes/sec
RP/0/RP0RSP0/CPU0:router#dir disk0a:/v6back
Directory of disk0a:
66016 -rwx 308413 Sun Oct 16 23:07:28 2011 v6back
2102788096 bytes total (2098987008 bytes free)
In the following example, user admin is downloading the file sampfile from disk0: to disk0a:/sampfile_v4 on a local SFTP server using an IPv4 address:
RP/0/RP0RSP0/CPU0:router#sftp admin@2.2.2.2:disk0:/sampfile disk0a:/sampfile_v4
Connecting to 2.2.2.2...
Password:
disk0:/sampfile
Transferred 986 Bytes
986 bytes copied in 0 sec (493000)bytes/sec
RP/0/RP0RSP0/CPU0:router#dir disk0a:/sampfile_v4
Directory of disk0a:
131520 -rwx 986 Tue Oct 18 05:37:00 2011 sampfile_v4
502710272 bytes total (502001664 bytes free)
In the following example, user admin is uploading the file sampfile_v4 from disk0a: to disk0:/sampfile_back on a local SFTP server using an IPv4 address:
RP/0/RP0RSP0/CPU0:router#sftp disk0a:/sampfile_v4 admin@2.2.2.2:disk0:/sampfile_back
Connecting to 2.2.2.2...
Password:
disk0a:/sampfile_v4
Transferred 986 Bytes
986 bytes copied in 0 sec (564000)bytes/sec
RP/0/RP0RSP0/CPU0:router#dir disk0:/sampfile_back
Directory of disk0:
121765 -rwx 986 Tue Oct 18 05:39:00 2011 sampfile_back
524501272 bytes total (512507614 bytes free)