boto.manage.cmdshell मॉड्यूल का उपयोग करने के लिए इसका उपयोग किया जा सकता है। इसका उपयोग करने के लिए, आपके पास paramiko पैकेज स्थापित होना चाहिए। इसका उपयोग का एक सरल उदाहरण:
import boto.ec2
from boto.manage.cmdshell import sshclient_from_instance
# Connect to your region of choice
conn = boto.ec2.connect_to_region('us-west-2')
# Find the instance object related to my instanceId
instance = conn.get_all_instances(['i-12345678'])[0].instances[0]
# Create an SSH client for our instance
# key_path is the path to the SSH private key associated with instance
# user_name is the user to login as on the instance (e.g. ubuntu, ec2-user, etc.)
ssh_client = sshclient_from_instance(instance,
'<path to SSH keyfile>',
user_name='ec2-user')
# Run the command. Returns a tuple consisting of:
# The integer status of the command
# A string containing the output of the command
# A string containing the stderr output of the command
status, stdout, stderr = ssh_client.run('ls -al')
वह स्मृति से टाइप किया गया था लेकिन मुझे लगता है कि यह सही है।
आप फैब्रिक (http://docs.fabfile.org/) भी देख सकते हैं जिसमें समान कार्यक्षमता है लेकिन इसमें अधिक परिष्कृत सुविधाएं और क्षमताएं भी हैं।
संपादन के लिए धन्यवाद स्टीफन। सुधार याद रखेंगे। – vibhor
संबंधित: [एसएसएच कैसे करें और boto3 का उपयोग कर ईसी 2 में आदेश चलाएं?] (Https://stackoverflow.com/q/42645196/55075) – kenorb