Ansible PreferredAuthentications SSH 設定從何而來?

Ansible PreferredAuthentications SSH 設定從何而來?

我正在使用 SSH 用戶名和密碼設定來運行標準 ansible (v2.3.1) 劇本。使用“-vvvv”設定時,我可以看到產生這些 SSH 命令

EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s 
-o StrictHostKeyChecking=no -o Port=2222 
-o KbdInteractiveAuthentication=no 
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o User=dc_user -o ConnectTimeout=10

在上面的範例中,「PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey」設定是從哪裡提取的。我相信這些來自客戶端 SSH 配置設置,但這正確嗎?

我知道我可以透過在“ansaible.cfg”中定義它來覆蓋 ssh 參數

[ssh_connection]
scp_if_ssh=True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey

誰可以給我解釋一下這個?謝謝

答案1

我觀察到這-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey是硬編碼的原始碼

如果您覆蓋ssh_argsto添加到 ssh 命令行ansible.cfg-o PreferredAuthentications=publickey但這不會替換-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey

例子:

$ grep ssh_args /etc/ansible/ansible.cfg 
#ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o     PreferredAuthentications=publickey
$ ansible rhel7a -m ping -vvvv |grep EXEC
<rhel7a> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/home/user/.ansible/cp/13dd447a86 rhel7a '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''

相關內容