Issues trying to SSH into a fresh EC2 instance with Paramiko

后端 未结 5 2371
执念已碎
执念已碎 2021-02-14 14:28

I\'m working on a script that spins up a fresh EC2 instance with boto and uses the Paramiko SSH client to execute remote commands on the instance. For whatever reason, the Param

5条回答
  •  滥情空心
    2021-02-14 14:43

    I recently view this code and I have a suggestion for code, Instead of running while loop to check whether the instance is running or not, you can try "wait_until_running()".

    Following is the sample code...

    client = boto3.resource(
        'ec2',
        region_name="us-east-1"
    )
    
    Instance_ID = ""
    instance = client.Instance(Instance_ID)
    instance.start()
    instance.wait_until_running()
    

    After that try to code for the ssh connection code.

提交回复
热议问题