使用 SSH 连接到 Amazon EC2 实例时禁用身份不明的主机确认
我正在使用 boto 和 Python 编写一个脚本来自动启动 Amazon EC2 实例并使用 SSH 与其交互。一切正常,除了每次建立连接时,SSH 都会提示我确认主机的真实性,如下所示:
The authenticity of host 'ec2-174-129-121-25.compute-1.amazonaws.com (174.129.121.25)' can't be established.
RSA key fingerprint is 26:09:bd:21:4f:55:20:3f:0d:fc:5f:cc:3e:08:30:db.
Are you sure you want to continue connecting (yes/no)?
我的 SSH 命令是:
ssh -i ssh2.pem [email protected]
由于每个 EC2 实例都是新主机,因此我每次都必须确认这一点,但我想无需任何用户输入的自动脚本。最好的解决方案是什么?
I am writing a script using boto and Python to automatically launch an Amazon EC2 instance and interact with it using SSH. Everything works fine except that every time I establish the connection, SSH prompts me to confirm the authenticity of the host like this:
The authenticity of host 'ec2-174-129-121-25.compute-1.amazonaws.com (174.129.121.25)' can't be established.
RSA key fingerprint is 26:09:bd:21:4f:55:20:3f:0d:fc:5f:cc:3e:08:30:db.
Are you sure you want to continue connecting (yes/no)?
My SSH command is:
ssh -i ssh2.pem [email protected]
Since every EC2 instance is a new host, I have to confirm this every time, but I want an automatic script without any user input. What is the best solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
-O StrictHostKeyChecking=no
并可以选择设置 /dev/null 的KnownHostsFile
(如果您想完全不安全的话)。但请记住,您正在绕过旨在保护您的安全措施!编辑,可能还有
CheckHostIP=no
。man ssh
并查看所有血淋淋的内容。Use
-O StrictHostKeyChecking=no
and, optionally, set theKnownHostsFile
of /dev/null (if you want to be totally insecure about things). But remember, you're bypassing security measures meant to protect you!edit and probably
CheckHostIP=no
too.man ssh
and see all the gory bits.对于 PuTTY 和 Windows,您可以使用
For PuTTY and windows you can use