您的位置:首页 > 其它

ansible密码认证,为新系统添加key

2018-03-29 14:07 204 查看
1、在文件/etc/ansible/hosts中定义变量

示例:

[HOSTGROUP]

web[1:9].fun.com

[HOSTGROUP:vars]

ansible_ssh_user="fun"

ansible_ssh_pass="funpass"

2、添加认证key

ansible HOSTGROUP -m authorized-key -a "user=fun key={{ lookup('file', '~/.ssh/id_rsa.pub') }}"

错误:Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host.

1、安装sshpass模块:sudo yum install sshpass -y

2、修改配置文件:/etc/ansible/ansible.cfg

host_key_checking = False

ask_pass = True
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: