0

I have two databases one on my local machine and one on my amazon ec2 instance.Now what I do is I run a python program on my local machine which makes changes to the databse on my local machine.I want these changes to be reflected onto the database on amazon ec2 instance, periodically.I want to do this in python.A script that logs onto the amazon server establishes a connection with the database there and makes the changes.
I came across some modules like pexcept,fabric and paramiko.But I am struggling with the key authentication.
The way I ssh from my terminal is ssh -i my_rsa_file.pem username@ip_address.There is no password.How do I go about this ?? Also I want to know whether simply using Popen in subprocess to execute the login command work ?

4

1 回答 1

0

此处的 Boto EC2 文档描述了 EC2 实例对象,其中“key_pair”是一个属性。在“boto.ec2.instance”下查看大约 3/4 的位置。

http://boto.readthedocs.org/en/latest/ref/ec2.html

因此,例如,您可以按如下方式运行一些实例,然后将第一个实例存储为“inst”:

reservation = conn.run_instances(...)
inst = reservation.instances[0]

要将您的密钥对名称检索为 unicode 字符串,只需使用:

kp_name = inst.key_name

然后,您可以使用 get_key_pair 检索相应的 Boto 对象:

kp_obj = conn.get_key_pair(kp_name)

当然,这是一个愚蠢的例子,因为我首先需要我的密钥对名称来运行_instances。愿您找到更富有成效的应用程序!

于 2013-09-16T12:56:45.913 回答