LinuxProbe 发表于 2021-5-21 03:08:53

Centos7部署轻量级自动化运维工具pssh


pssh是由python编写,可以在多台服务器执行命令的工具。在服务器越来越多的企业这种自动化运维工具越来越火。
https://www.linuxprobe.com/wp-content/uploads/2020/06/1.jpg下载pssh安装包
# wget https://files.pythonhosted.org/packages/60/9a/8035af3a7d3d1617ae2c7c174efa4f154e5bf9c24b36b623413b38be8e4a/pssh-2.3.1.tar.gz安装依赖包
# yum install -y make gcc gcc++ python-devel python-pip安装pssh
# tar xf pssh-2.3.1.tar.gz# cd pssh-2.3.1# python setup.py install配置免密登录
# ssh-keygenGenerating public/private rsa key pair.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:SHA256:3antaxjGw+hdgfSlrXLYhUe5vgHe9b0ehh/gUY9E8Eg root@localhost.localdomainThe key's randomart image is:+-------+|            E... ||          .. ++||         . o.*oo ||         ...*o*.o||      S+.+o@..+||      . OoB B o||       . o.B.o *.||      . o.. +.o||         .o..o |+---------+# cd /root/.ssh/# lsid_rsaid_rsa.pub# ssh-copy-id 172.16.1.112/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"The authenticity of host '172.16.1.112 (172.16.1.112)' can't be established.ECDSA key fingerprint is SHA256:yFvaxR1x5YDhhe+6xR/Ou6Sm+YPYvPAoiLVKt9mAnXA.ECDSA key fingerprint is MD5:0d:c4:79:bc:36:7a:a4:82:95:4f:d5:d0:a3:c8:7d:2e.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 keysroot@172.16.1.112's password: Number of key(s) added: 1Now try logging into the machine, with:   "ssh '172.16.1.112'"and check to make sure that only the key(s) you wanted were added.# ssh-copy-id 172.16.1.16/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"The authenticity of host '172.16.1.16 (172.16.1.16)' can't be established.ECDSA key fingerprint is SHA256:ANzlXzrGA87YLI2vzkPJ/iNPiSQ5JStJc95948jE8aw.ECDSA key fingerprint is MD5:f9:f1:1b:5a:99:64:d8:d8:e9:9b:e6:bb:c3:d5:bd:e7.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 keysroot@172.16.1.16's password: Number of key(s) added: 1Now try logging into the machine, with:   "ssh '172.16.1.16'"and check to make sure that only the key(s) you wanted were added.测试免密登录
# ssh 172.16.1.112Last login: Tue Jun2 09:44:24 2020 from 172.16.1.16# ssh 172.16.1.16Last login: Tue Jun2 09:30:47 2020 from 172.16.1.100测试pssh
创建aaa文件存放ip地址
# cat aaa172.16.1.16172.16.1.112批量执行date命令
# pssh -h aaa -l root -P "date"172.16.1.16: 2020年 06月 02日 星期二 09:59:48 CST 09:59:48 172.16.1.16172.16.1.112: 2020年 06月 02日 星期二 09:59:48 CST 09:59:48 172.16.1.112查看磁盘
# pssh -h aaa -l root -P "lsblk"172.16.1.16: NAME            MAJ:MIN RMSIZE RO TYPE MOUNTPOINTsda               8:0    0   20G0 disk ├─sda1            8:1    0    1G0 part /boot└─sda2            8:2    0   19G0 part   ├─centos-root 253:0    0   17G0 lvm/└─centos-swap 253:1    0    2G0 lvmsr0            11:0    14.2G0 rom 10:13:02 172.16.1.16172.16.1.112: NAME            MAJ:MIN RMSIZE RO TYPE MOUNTPOINTsda               8:0    0   20G0 disk ├─sda1            8:1    0    1G0 part /boot└─sda2            8:2    0   19G0 part   ├─centos-root 253:0    0   17G0 lvm/└─centos-swap 253:1    0    2G0 lvmsr0            11:0    14.2G0 rom 10:13:03 172.16.1.112pssh部署完毕!

fjq0215 发表于 2021-5-21 07:45:52

感觉挺有意思的

dy4323 发表于 2021-10-9 12:53:39

谢谢分享

qqqiang0222 发表于 2023-5-6 16:54:43

{:6_267:}

CHT5011 发表于 2023-5-29 09:31:47

{:6_264:}{:6_264:}{:6_269:}{:6_269:}{:6_265:}{:6_265:}{:6_273:}{:6_273:}{:6_280:}{:6_280:}{:6_278:}{:6_285:}{:6_289:}{:6_298:}{:6_295:}
页: [1]
查看完整版本: Centos7部署轻量级自动化运维工具pssh