基于sshpass分布密钥

1:基于sshpass 分布密钥

《1》:yum -y install sshpass  安装sshpass (注:这里不需要安装,因为在安装ansible的时候已经安装了)

《2》:sshpass -p gzf123. ssh-copy-id  root@192.168.100.20   分发时不需要密码

 他的格式:Ansible 组名   -m   模块   -a  参数

《3》:ansible webserver -m command -a "touch /tmp/11111"   (注:command 是支持shell命令的)

《4》:vim /etc/ansible/hosts  编辑文件。(注:删除虚拟机2的密钥对,不需要创建密钥对,也可以)

《5》:写入:(注:客户机名称,对应的地址,用户,密码:写root的密码)

[nokey]

 client1 ansible_ssh_host=192.168.100.20 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=gzf123.

《6》:ansible nokey -m ping  ping  也是可以的

《7》:sshpass -pgzf123. ssh-copy-id root@192.168.100.10  (注:在删除对方密钥对的后,建议去传输密钥对,但是不传也是可以的)

《8》:ansible webserver -m ping   回到原来的组

《9》:ansible webserver -m ping --limit 192.168.100.20   仅对192.168.100.20生效

《10》:ansible 192.168.100.20 -m ping (注:直接写入IP地址,也就是仅对于192.168.100.20生效)

《11》:ansible 192.168.100.* -m ping  (注:只对一个网段生效,*代表任意的)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BK_小小关

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值