Created
January 1, 2022 21:59
-
-
Save ZhouYang1993/81d72cbab9e4c5167dfaeaee815f503b to your computer and use it in GitHub Desktop.
Server Automation in Python: Unleash Your Productivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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