为 EC2 配置结构
我正在尝试创建一个 fabfile.py 以便可以在 EC2 上部署。我的 fabfile.py 中有以下内容:
from __future__ import with_statement
from fabric.api import *
def ec2():
env.hosts = ['111.111.111.111']
env.user = 'ubuntu'
env.key_filename = '/path/to/my/pem/key.pem'
def run_ls():
run('ls -alt')
“111.111.111.111”是我的实例的弹性 IP,我总是使用 ubuntu 登录,而不是 root。 当我运行以下命令时,
fab ec2 run_ls
我看到以下输出:
[111.111.111.111] Executing task 'run_ls'
[111.111.111.111] run: ls -alt
Fatal error: Host key for 111.111.111.111 did not match pre-existing key! Server's key was changed recently, or possible man-in-the-middle attack.
Aborting.
不确定发生了什么,但我找不到关于在 ec2 上使用 Fabric 的任何很棒的教程,而且我不知道这是怎么可能的。
谢谢
更新:
看起来
env.hosts = ['111.111.111.111']
无效,您需要使用
env.hosts = ['mywebsite.com']
解决我的问题的实际 URL
I am trying to create a fabfile.py so that I can deploy on EC2. I have the following in my fabfile.py:
from __future__ import with_statement
from fabric.api import *
def ec2():
env.hosts = ['111.111.111.111']
env.user = 'ubuntu'
env.key_filename = '/path/to/my/pem/key.pem'
def run_ls():
run('ls -alt')
'111.111.111.111' is the elastic ip of my instance, and i alway login with ubuntu, not root.
when i run the following command
fab ec2 run_ls
i see the following output:
[111.111.111.111] Executing task 'run_ls'
[111.111.111.111] run: ls -alt
Fatal error: Host key for 111.111.111.111 did not match pre-existing key! Server's key was changed recently, or possible man-in-the-middle attack.
Aborting.
Not sure what is going on, but I can't find to seem any great tutorials on using fabric on ec2, and I do not know how that is possible.
Thanks
Update:
Looks like
env.hosts = ['111.111.111.111']
is not valid, you need to use the actually URL
env.hosts = ['mywebsite.com']
which fixed my issue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还可以使用“--disable-known-hosts”开关来忽略此错误。
You can also use the '--disable-known-hosts' switch to ignore this error.
确保您的弹性 IP 已附加到实例。我认为 key_filename 采用单个参数,但当您传入数组时,我的参数正在工作:
也许您应该尝试使用实例的公共主机名,例如:
Make sure your elastic IP is attached to the instance. I think the key_filename takes a single argument but mine is working when you pass in an array instead:
Maybe you should try using the public hostname of your instance like:
从 GitHub 上的 Vagrant 问题 中,您可能需要从 <使用如下命令创建 code>known_hosts 文件:
From a Vagrant issue on GitHub, you may need to remove the host from the
known_hosts
file using a command like this: