Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python connect sftp with key

import pysftp

def upload_file(file_path):

    private_key = "~/.ssh/your-key.pem"  # can use password keyword in Connection instead
    srv = pysftp.Connection(host="your-host", username="user-name", private_key=private_key)
    srv.chdir('/var/web/public_files/media/uploads')  # change directory on remote server
    srv.put(file_path)  # To download a file, replace put with get
    srv.close()  # Close connection
Comment

PREVIOUS NEXT
Code Example
Python :: set axis ticks matplotlib 
Python :: printing with colors 
Python :: python wait 5 seconds then display 
Python :: filter nulla values only pandas 
Python :: f string float format 
Python :: how to check if a network port is open 
Python :: python list add if not present 
Python :: python plot bins not lining up with axis 
Python :: python randomize list 
Python :: static and media files in django 
Python :: python tkinter listbox click event 
Python :: which python mac 
Python :: python has duplicates 
Python :: python pandas csv to xlsx semicolon 
Python :: convert c_ubyte_Array_ to opencv 
Python :: flower not implemented error 
Python :: print every element in list python outside string 
Python :: remove special characters from dictionary python 
Python :: matplotlib subtitle 
Python :: group consecutive numbers in list python 
Python :: how to make a bot say hello <username when a user says hello in discord with python 
Python :: you are trying to access thru https but only allows http django 
Python :: init image with zeros python 
Python :: media url django 
Python :: printing hollow triangle in python 
Python :: convert tibble to dataframe 
Python :: python program to find all prime numbers within a given range 
Python :: create a sequence of numbers in python 
Python :: python discord bot wait for response 
Python :: bs4 find element by id 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =