Using the Paramiko module to copy remote files to a local

Source: Internet
Author: User

The script is as follows:

# cat myscp.py #!/usr/bin/env pythonimport paramikoimport oshostname = ' 192.168.56.101 ' port = 22username = ' Root ' pa ssWOrd = ' 111111 ' Dir_path = '/root/perl ' if __name__ = = ' __main__ ': t = Paramiko. Transport ((hostname, port)) T.connect (Username=username, password=password) sftp = Paramiko. Sftpclient.from_transport (t) files = Sftp.listdir (Dir_path) for F in Files:print ' retrieving ', F sft P.get (Os.path.join (Dir_path, F), F) t.close ()


The results of the implementation are as follows:

# python myscp.py retrieving 10_29.plretrieving 10_30.plretrieving 10_28.plretrieving 10_27.pl# ls *.pl10_27.pl 10_28.pl 10_29.pl 10_30.pl


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/44/wKiom1XfxYSSxUbzAAjw7pLI6_w181.jpg "title=" python _paramiko_scp.png "alt=" Wkiom1xfxyssxubzaajw7pli6_w181.jpg "/>

This article is from the "Tiandaochouqin" blog, make sure to keep this source http://lavenliu.blog.51cto.com/5060944/1689184

Using the Paramiko module to copy remote files to a local

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.