ansible不配ssh链接,用户密码登陆

ansible 不配ssh免密连接,直接用ssh用户密码链接,要先装sshpass。html

sshpass下载地址:http://sourceforge.net/projects/sshpass/ssh

运行下列命令安装:ide

tar -zxvf sshpass-1.05.tar.gz
cd sshpass-1.05                
./configure             
make && make install

安装完成后输入sshpass出现以下提示即安装成功:this

# sshpass
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
   -f filename   Take password to use from file
   -d number     Use number as file descriptor for getting password
   -p password   Provide password as argument (security unwise)
   -e            Password is passed as env-var "SSHPASS"
   With no parameters - password will be taken from stdin
   -h            Show help (this screen)
   -V            Print version information
At most one of -f, -d, -p or -e should be used

/etc/ansible/hosts文件中添加用户密码,认证ssh链接.net

[test]
127.0.0.1 ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass=123456
192.168.1.103 ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass=123456

错误汇总:code

[root@localhost ~]# ansible test -m ping
127.0.0.1 | FAILED! => {
    "msg": "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."
}
192.168.1.103 | FAILED! => {
    "msg": "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."
}

ssh第一次链接的时候通常会提示输入yes 进行确认为将key字符串加入到 ~/.ssh/known_hosts 文件中。而本机的~/.ssh/known_hosts文件中并有fingerprint key串orm

解决方法:在ansible.cfg文件中更改下面的参数:htm

#host_key_checking = False 将#号去掉便可blog

参考网址:ip

https://www.cnblogs.com/iois/p/6230800.html

http://www.javashuo.com/article/p-xzlpobrl-v.html

相关文章
相关标签/搜索