How to transfer a file from Junos device

392 views
Skip to first unread message

Mike Strube

unread,
Apr 2, 2015, 10:57:34 AM4/2/15
to junos-p...@googlegroups.com
I've generated a tarball file of the /var/log directory on a switch in /var/tmp.  Now, I want to transfer it to the machine I'm running PyEZ on.  The only protocol I have available is SSH/SCP -- no FTP or TFTP.  I can't use sshkeys because I'm using the 'root' user on the switch due to file permissions of the logs and of the tarball.  I do have the root password, but can't seem to find a way to pass it.  

Rick Sherman

unread,
Apr 2, 2015, 11:34:40 AM4/2/15
to junos-p...@googlegroups.com
Hi Mike, 

You can use the SCP utility.  This creates a SCPClient object.

from jnpr.junos.utils.scp import SCP
with SCP(dev) as scp:
    scp
.get('/cf/var/tmp/gksdchk.log', './gksdchk.log')

https://github.com/jbardin/scp.py/blob/master/scp.py#L152-L153

-Rick

Mike Strube

unread,
Apr 2, 2015, 12:53:44 PM4/2/15
to junos-p...@googlegroups.com
That works, but with the following warning:

No handlers could be found for logger "paramiko.transport"

Also, the examples indicate an additional parameter, progress=_scp_progress, but if I include it python complains about it not being defined...  It would be nice to get a progress indication...

Rick Sherman

unread,
Apr 2, 2015, 1:35:18 PM4/2/15
to junos-p...@googlegroups.com
Hi Mike,

I'll fix/add both of these to the SCP util.

In the mean time, I'll unicast you a script that works around both.

Thanks,
-Rick
Reply all
Reply to author
Forward
0 new messages