如何在不使用paramiko模块的情况下使用python使用pem键登录EC2实例,以下代码与paramiko有效,但我需要没有paramiko。
def ssh_login(self):
try:
cert = paramiko.RSAKey.from_private_key_file("key.pem")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print "connecting..."
c.connect( hostname = "10.0.0.0", username = "example", pkey = cert )
print "connected!!!"
stdin, stdout, stderr = c.exec_command('ls')
print stdout.readlines()
c.close()
except:
print("Connection Failed!!!")