I'm trying to write a script that will take a single string (machine name) and use Amazon API to find that machine and get the DNS and SSH into the machine. If it were a bash script I could simply put in an ssh command and it would create the connection and the user wouldn't notice anything. How do I do that in Python though? I essentially want the script to end and the terminal to SSH into the machine.
For querying EC2 resources, use the boto library.
For running the ssh, use the subprocess.call (no need to end the script though).
import subprocess
addr = '10.20.30.40'
subprocess.call([ 'ssh', addr ])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With