cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3584
Views
5
Helpful
6
Replies

using EEM to transfer file using SFTP

nikos_skalis
Level 1
Level 1

Hello All,

I would need your help about the following :

let's say that I have a file stored on "disk0a:/usr/" and it's name is "_debug.dat"

and I want to transfer that file using SSH to home directory "nikos" on the server "1.1.1.1" and the password would be "123abc!"

So, teh command would be :

sftp disk0a:/usr/_debug.dat nikos@1.1.1.1:/home/nikos/

then I'll be prompted for password, and the transfer will be completed.

My question is how to do that using Tcl/EEM and without be prompted for password ?

I know that there is a -force option, but I haven't made it working.

Kind Regards,

Nikos

6 Replies 6

Joe Clarke
Cisco Employee
Cisco Employee

You will always be prompted, but you can answer the prompt within EEM.  For example:

cli_write $cli(fd) "sftp disk0a:/usr/_debug.dat nikos@1.1.1.1:/home/nikos/"

cli_read_pattern $cli(fd) "password"

cli_write $cli(fd) "123abc!"

Thank you Joseph,

Here is what was written :

set    cmd "sftp disk0a:/usr/flow01_key

labmin@1.1.1.1:/home/labmin/

" ;

if [ catch {cli_write $clifd(fd) $cmd} rc ] {

        error $rc $errorInfo

}

if [ catch {cli_read_pattern $clifd(fd) "Password:"} rc ] {

        error $rc $errorInfo

}

if [ catch {cli_write $clifd(fd) "abc123!"} rc ] {

        error $rc $errorInfo

}

but, what I see in the logs is :

RP/0/RSP0/CPU0:Oct 19 10:47:48.012 CET: ssh[65866]: %SECURITY-SSHD-3-ERR_SYSDB_DELETE : sysdb_item_delete failed for tuple 28488010 in function ssh_kexinfo_tuple()

do you have any idea how to bypass this ?

This doesn't appear to be an EEM problem per se, but a problem with SSH on the device.  Unfortunately, I don't have an IOS-XR device with which to test, but I don't see any problem in this code (provided the sftp command prompt does contain the pattern "Password:").

I didn't think Cisco supported sftp?

Router#copy running-config ?

  archive:        Copy to archive: file system

  flash:          Copy to flash: file system

  ftp:            Copy to ftp: file system

  http:           Copy to http: file system

  https:          Copy to https: file system

  idconf          Load an IDConf configuration file

  null:           Copy to null: file system

  nvram:          Copy to nvram: file system

  rcp:            Copy to rcp: file system

  running-config  Update (merge with) current system configuration

  scp:            Copy to scp: file system

  startup-config  Copy to startup configuration

  syslog:         Copy to syslog: file system

  system:         Copy to system: file system

  tftp:           Copy to tftp: file system

  tmpsys:         Copy to tmpsys: file system

Thanks, Pat

The question here is about IOS-XR.

Oh, ok.

Review Cisco Networking for a $25 gift card