私は多くの進歩を遂げました。AWS Python - Windows - インスタンスを作成した後にスクリプトを実行する
私の輸入は、以下のとおりです。
import boto.rds as rds
import boto3 as b3
import boto.ec2 as ec2
from boto.manage.cmdshell import sshclient_from_instance
私が使用して私のAWSに接続することができます。私がしようとすると、
conn_args = {
'aws_access_key_id': 'MY_KEY',
'aws_secret_access_key': 'MY_PASS',
'region_name': 'us-west-2'
}
ec2_res = b3.resource('ec2', **conn_args)
new_instance = ec2_res.create_instances(
ImageId='ami-123456',
MinCount=1,
MaxCount=1,
InstanceType='t2.micro',
KeyName='my-keyname',
SecurityGroups=[
'my-securitygroup'
]
)
を今すぐ:
conn = boto.ec2.connect_to_region('us-west2',aws_access_key_id='MY_ID', aws_secret_access_key='MY_PASS')
私が使用してインスタンスを作成することができます私の新しいインスタンスでコマンドを実行する私は壁に頭を打つ。
私が何かしようとしています:
ssh_client = sshclient_from_instance(instance,
'C:\\users\\%USER%\\aws\\windows-west-keypair.pem',
user_name='Administrator')
status, stdout, stderr = ssh_client.run('cd')
をしかし、私は戻って取得:私のAWSインスタンスにssh経由で接続
C:\Users\%USER%\Miniconda\lib\site-packages\paramiko\hostkeys.pyc in load(self, filename)
93 :raises IOError: if there was an error reading the file
94 """
---> 95 with open(filename, 'r') as f:
96 for lineno, line in enumerate(f, 1):
97 line = line.strip()
IOError: [Errno 2] No such file or directory: 'C:\\Users\\%USER%/.ssh/known_hosts'
は私にとって新しいものであるので、私はにそこに期待していませんディレクトリ/ファイルです。
何が必要なのですか?事前にインストールする必要があるものはありますか?何が間違っているのでしょうか?
私はとても近づいていると感じています。
助けがあれば助かります。
Windowsインスタンスですか? – error2007s
@ error2007sはい、Windowsインスタンスです。 –
pemファイルを使用してWindowsインスタンスにSshすることはできません。この手順をチェックしてAWS Windows EC2インスタンスに接続してください。http://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-rdp.html – error2007s