| [root@vm04 ~]# yum -y install epel-release.noarch |
| |
| [root@vm04 ~]# yum install -y ansible |
| |
| [root@vm04 ~]# yum install -y tree |
| |
| [root@vm04 ~]# tree /etc/ansible/ |
| /etc/ansible/ |
| ├── ansible.cfg |
| ├── hosts |
| └── roles |
| |
| 1 directory, 2 files |
| [root@vm04 ~]# vim /etc/ansible/hosts |
| [root@vm04 ~]# ssh-keygen -t rsa |
| Generating public/private rsa key pair. |
| Enter file in which to save the key (/root/.ssh/id_rsa): |
| Created directory |
| 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: |
| SHA256:FwtTwK3KeCzoxL2apfMxX66Rv5kHsP84Z1VFipiM92Y root@vm04 |
| The key |
| +---[RSA 2048]----+ |
| | ..o. ..| |
| | .+.o . ..| |
| | +.* . .. | |
| | . .+ + . | |
| | . o + +S o E. | |
| | + + *... o. | |
| | o ++o... . | |
| | o+.+ =o++ | |
| | ++. o.BB. | |
| +----[SHA256]-----+ |
| [root@vm04 ~]# |
| [root@vm04 ~]# vim /etc/ansible/hosts |
| [root@vm04 ~]# ssh-copy-id root@192.168.161.132 |
| /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" |
| The authenticity of host |
| ECDSA key fingerprint is SHA256:5uR5JPMqsz41rj41ucvYjTJQXyriDSExMIxriedz/6M. |
| ECDSA key fingerprint is MD5:8f:c1:f9:38:a8:e2:74:ef:7d:f5:1a:b0:41:de:90:8a. |
| Are you sure you want to continue connecting (yes/no)? yes |
| /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed |
| /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys |
| 1root@192.168.161.132 |
| Permission denied, please try again. |
| root@192.168.161.132 |
| |
| Number of key(s) added: 1 |
| |
| Now try logging into the machine, with: "ssh 'root@192.168.161.132'" |
| and check to make sure that only the key(s) you wanted were added. |
| |
| [root@vm04 ~]# ssh-copy-id root@192.168.161.133 |
| /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" |
| The authenticity of host |
| ECDSA key fingerprint is SHA256:5uR5JPMqsz41rj41ucvYjTJQXyriDSExMIxriedz/6M. |
| ECDSA key fingerprint is MD5:8f:c1:f9:38:a8:e2:74:ef:7d:f5:1a:b0:41:de:90:8a. |
| Are you sure you want to continue connecting (yes/no)? yes |
| /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed |
| /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys |
| root@192.168.161.133 |
| |
| Number of key(s) added: 1 |
| |
| Now try logging into the machine, with: "ssh 'root@192.168.161.133'" |
| and check to make sure that only the key(s) you wanted were added. |
| |
| [root@vm04 ~]# ansible 192.168.161.132 -m command -a |
| 192.168.161.132 | CHANGED | rc=0 >> |
| 2024年 03月 15日 星期五 00:15:12 CST |
| [root@vm04 ~]# ansible mysql -m command -a |
| 192.168.161.133 | CHANGED | rc=0 >> |
| 2024年 03月 15日 星期五 00:15:37 CST |
| |
| |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异