Wednesday 16 October 2019

Remote connection to AWS EC2 Linux Instance in Python

import paramiko

##Initiate SSH Connection
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(hostname=<host_ip>,port=<port>,username<username>,key_filename=<keypath>)
print("Connection Successfully Established!")
except paramiko.AuthenticationException:
print("Authentication Failed!")

No comments:

Post a Comment