Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Created January 1, 2022 21:59
Show Gist options
  • Save ZhouYang1993/81d72cbab9e4c5167dfaeaee815f503b to your computer and use it in GitHub Desktop.
Save ZhouYang1993/81d72cbab9e4c5167dfaeaee815f503b to your computer and use it in GitHub Desktop.
Server Automation in Python: Unleash Your Productivity
import paramiko
HOST = 'x.xxx.xxx.xxx' # The IP Address of my server
NAME = 'yang'
key = paramiko.RSAKey.from_private_key_file("yangAWS.pem")
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=HOST, username=NAME, pkey=key)
sftp = client.open_sftp()
sftp.put("image_cleaner.sh", "/home/yang/images/image_cleaner.sh")
# do something...
client.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment