使用 SSH 连接到 Amazon EC2 实例时禁用身份不明的主机确认

发布于 2024-08-17 06:04:01 字数 694 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怕倦 2024-08-24 06:04:01

使用 -O StrictHostKeyChecking=no 并可以选择设置 /dev/null 的 KnownHostsFile (如果您想完全不安全的话)。但请记住,您正在绕过旨在保护您的安全措施!

编辑,可能还有CheckHostIP=noman ssh 并查看所有血淋淋的内容。

Use -O StrictHostKeyChecking=no and, optionally, set the KnownHostsFile 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.

挥剑断情 2024-08-24 06:04:01

对于 PuTTY 和 Windows,您可以使用

echo y | plink -pw yourpassword [email protected]

For PuTTY and windows you can use

echo y | plink -pw yourpassword [email protected]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文