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 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.
Examples
In the following
example, user
abc
is downloading the file
ssh.diff from the SFTP server ena-view1
to
disk0:
RP/0/0/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/0/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/0/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/0/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/0/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/0/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/0/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/0/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/0/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/0/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)