My deployment aws environment is using bastion host to allow connection to all different aws ec2 machines. I am using paramiko and able to make connection with bastion.
pemkey_path = paramiko.RSAKey.from_private_key_file("xyz.pem")
paramiko_client = paramiko.SSHClient()
paramiko_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print("connecting")
bastion_conn = paramiko_client.connect( hostname = "ec2-xxx.compute.amazonaws.com", username = "ec2-user", pkey = pemkey_path)
print("connected")
Now I want to connect to ec2 instance from this bastion connection and perform some commands to this ec2-instance how can I do this ?