我怎么可以跳过光纤连接的询问密码?光纤、跳过、密码、我怎么

2023-09-11 09:19:26 作者:温习你给的温柔

我遍历几百个EC2实例,但只能获得约80%的人。我想跳过那些拒绝我的SSH密钥,并要求输入密码的任何实例。

I'm iterating over a few hundred EC2 instances but only have access to about 80% of them. I would like to skip any instances that have declined my SSH key and asked for a password.

推荐答案

如果主机不可达,那么你可以使用 - 跳坏主机选项,否则 貌似可以使用的设置上下文管理,并尝试在这方面管理的SSH,如果故障发生就可以跳到下一个。该文档的 context_manager.settings 有一个例子。

If the host is unreachable, then you can use --skip-bad-hosts option, otherwise Looks like you can use the settings context manager and try the ssh within that context manager and if the failure happens it can skip to the next one. The docs for context_manager.settings have an example.

with settings(warn_only=True):
    ssh_attempt # can fail
ssh_attemp # cannot fail