ansible添加主机认证
一、生成密钥
ssh-keygen
二、将密钥拷贝到目标主机
ssh-copy-id -i root@10.230.20.103
【ansible添加主机认证】遇到需要输入的地方直接回车
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
--------------------
The key's randomart image is:
--------------------
三、在主机列表中添加机器信息
[root@localhost ~]# vi /etc/ansible/hosts
10.230.20.103
四、对主机发送命令
[root@localhost ~]# ansible -m command -a 'ls' '10.230.20.103'
10.230.20.103 | SUCCESS | rc=0 >>
anaconda-ks.cfg
install.log
install.log.syslog
jboss
jboss-eap-6.2
redis-3.2.0.tar
zookeeper-3.4.6.tar.gz
命令执行成功
推荐阅读
- 方法(一键批量把联系人号码添加导入WhatsApp通讯录)
- Ubuntu添加非root用户到Docker用户组
- 刷新控件
- C#中ListView用法实例
- ansible安装与部署
- 数据库|mybatis-plus QueryWrapper 添加limit
- 资深运营(如何在公众号图文中添加附件,这其实一点都不难)
- 投稿|给主机游戏贴共享标签:“钱”景还是陷阱?
- docker|Docker --docker网络知识详解(原生网络、自定义网络、容器通信、跨主机容器网络)
- 怎么添加多张CAD图纸文件共同进行版本转换()