大网数据广告活动
服务器运维问答

Ansible where do PreferredAuthentications SSH settings come from?

· 52CE 我爱测

I'm running a standard ansible (v2.3.1) playbook using SSH username and password settings. When using the '-vvvv' setting i can see these SSH commands getting generated EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o S…

问题原文

原帖链接 · emeraldjava · CC BY-SA 4.0

I'm running a standard ansible (v2.3.1) playbook using SSH username and password settings. When using the '-vvvv' setting i can see these SSH commands getting generated

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

In the case above, where are the 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey' settings getting pulled from. I believe these come from the client SSH config settings but is this correct?

I understand that i can override the ssh arguments by defining this in my 'ansaible.cfg'

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

Can someone explain this to me? Thanks

已采纳解答

原帖链接 · NoNoNo · CC BY-SA 4.0

I'm observe that -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey is hard coded in the source code

If you override ssh_args in ansible.cfg to -o PreferredAuthentications=publickey is added to the ssh command line but this doesn't replace -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey

Example:

$ 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'"'"''

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。