Python uploads local files to SSH using the Paramiko module

Source: Internet
Author: User

We want to understand several functions:

Paramiko. Tranport (("Destination IP, port") #这是上传目标的IP和端口

  

Paramiko. Sftpclient.from_tranport () #安全文件传输凭证

  

Sftp.put (Loaclfile,remotefile) #loaclfile是要上传的文件, RemoteFile is the file name to save after uploading

Code version:

ImportParamikossh=paramiko. Transport (("192.168.223.129", 22)) Ssh.connect (username="Root", password="Root") sftp=Paramiko. Sftpclient.from_transport (SSH) LocalFile="instructions for use. txt"RemoteFile="instructions for use. txt"Try: Sftp.put (localfile,remotefile)exceptException:Print("[-]put error:user name or password Error or uploaded file does not exist")Print("Upload") Ssh.close ()

Success Chart:

Reprint Please note: from this address

Python uploads local files to SSH using the Paramiko module

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.