Untitled

 avatar
unknown
plain_text
2 years ago
446 B
18
Indexable
def get_private_nlb_ip(ssh_key, instance_ip):

    key_file = StringIO(ssh_key)
    private_key = paramiko.RSAKey.from_private_key(key_file)

    client = paramiko.SSHClient()

    client.connect(hostname=instance_ip, username='ec2-user', pkey=private_key)
    command = 'pwd'
    ssh_stdin, ssh_stdout, ssh_stderr = client.exec_command(command)
    for line in ssh_stdout.readlines():
        print(line)
    client.close()
    key_file.close()
Editor is loading...