gpt4 book ai didi

ssh - 是否可以告诉 ansible 不使用 ~/.ssh/config?

转载 作者:行者123 更新时间:2023-12-02 13:46:45 24 4
gpt4 key购买 nike

我的 ~/.ssh/config文件干扰 ansible,我在那里使用了很多缩写,以便在登录服务器时更轻松。

例如在:

Host te*
HostName %h.example.com
User test

在我的 ansible hosts 文件中,我有:
[servers]
te1.exmaple.com
te2.example.com

这意味着当我运行 ansible 时,连接将失败,因为它将使用我的 ssh 配置文件并尝试连接到 te1.example.com.example.com .

我知道我可以将 ansible 主机修改为 te1 并让 ssh config 添加域的其余部分,但我知道我团队的其他成员没有像我一样设置他们的 .ssh/config 所以这不是真的一个选项,而 tbh 是一条简单的路线,最终会给其他人带来问题。

有没有办法告诉它不要使用我的或其他任何人 .ssh/config文件?

最佳答案

您可以使用 ANSIBLE_SSH_ARGS parameteransible.cfg为了那个原因。所需的 ssh 参数是 -F configfile具有以下含义:

-F configfile

Specifies an alternative per-user configuration file. If aconfiguration file is given on the command line, the system-wideconfiguration file (/etc/ssh/ssh_config) will be ignored. The defaultfor the per-user configuration file is ~/.ssh/config.


所以你的 ANSIBLE_SSH_ARGS默认值在 ansible.cfg然后看起来像这样:
ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s -F /dev/null

关于ssh - 是否可以告诉 ansible 不使用 ~/.ssh/config?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54180805/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com