Centos7中安装轻量级运维利器:pssh

pssh 提供了并行版本的 OpenSSH 工具,特别适合用来控制有大量机器需要连接的情况,包括并行版本的 ssh、scp、rsync 和 kill 命令。

下载pssh安装包

[root@localhost ~]# wget https://files.pythonhosted.org/packages/60/9a/8035af3a7d3d1617ae2c7c174efa4f154e5bf9c24b36b623413b38be8e4a/pssh-2.3.1.tar.gz

安装依赖包

[root@localhost ~]# yum install -y make gcc gcc++ python-devel python-pip

安装pssh

[root@localhost ~]# tar xf pssh-2.3.1.tar.gz
[root@localhost ~]# cd pssh-2.3.1
[root@localhost ~]# python setup.py install

配置免密登录

[root@localhost ~]# ssh-keygen
Generating 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 [email protected]
The key's randomart image is: +---[RSA 2048]----+ |            E... | |          .. ++  | |         . o.*oo | |         ...*o*.o| |        S+.+o@..+| |        . OoB B o| |       . o.B.o *.| |        . o.. +.o| |           .o..o | +----[SHA256]-----+ [root@localhost ~]# cd /root/.ssh/ [root@localhost .ssh]# ls id_rsa  id_rsa.pub [root@localhost .ssh]# 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 keys
[email protected]'s password: Number of key(s) added: 1 Now 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. [root@localhost .ssh]# 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 keys
[email protected]'s password: Number of key(s) added: 1 Now 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. 

测试免密登录

[root@localhost ~]# ssh 172.16.1.112
Last login: Tue Jun  2 09:44:24 2020 from 172.16.1.16
[root@localhost ~]# ssh 172.16.1.16
Last login: Tue Jun  2 09:30:47 2020 from 172.16.1.100

测试pssh

创建aaa文件存放ip地址

[root@localhost ~]# cat aaa
172.16.1.16
172.16.1.112

批量执行date命令

[root@localhost ~]# pssh -h aaa -l root -P "date"
172.16.1.16: 2020年 06月 02日 星期二 09:59:48 CST
[1] 09:59:48 [SUCCESS] 172.16.1.16
172.16.1.112: 2020年 06月 02日 星期二 09:59:48 CST
[2] 09:59:48 [SUCCESS] 172.16.1.112

查看磁盘

[root@localhost ~]# pssh -h aaa -l root -P "lsblk"
172.16.1.16: NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   19G  0 part
 ├─centos-root 253:0    0   17G  0 lvm  /
 └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sr0              11:0    1  4.2G  0 rom  
[1] 10:13:02 [SUCCESS] 172.16.1.16
172.16.1.112: NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   19G  0 part
 ├─centos-root 253:0    0   17G  0 lvm  /
 └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sr0              11:0    1  4.2G  0 rom  
[2] 10:13:03 [SUCCESS] 172.16.1.112

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/10227.html

(0)
晴川运维晴川运维
上一篇 2025年6月23日
下一篇 2025年6月23日

相关推荐

  • 安装CentOS6.5时提示“sda 必须有一个GPT磁盘标签” 错误

    今天在thinkpad t430u上安装CentOS6.5 时总共遇到了两个问题: 1> U盘安装CentOS 6.5 时,选择安装时,报错信息为 ACPI: BIOS _O…

    CentOS 2025年10月9日
  • Centos7.7中安装Xrdp

    Xrdp是一个开源工具,允许用户通过Windows RDP访问Linux远程桌面。 除了Windows RDP之外,xrdp工具还接受来自其他RDP客户端的连接,如FreeRDP,…

    CentOS 2025年9月20日
  • CentOS安装最新版本GitHub

    由于centos仓库中Git的版本没及时更新,一直停留在了1.7.1,但git最新版本已经到了2.x.x,对于想要获取最新git的系统,只能下rpm包或者用源码;具体方法如下操作:…

    CentOS 2025年6月30日
  • CentOS 7中安装Snapd具体步骤

    CentOS 7中如何安装Snapd?本篇文章为大家分享一下CentOS 7安装Snapd具体步骤,有需要的小伙伴可以参考一下。 1、首先安装COPR插件和EPEL,通过添加epe…

    CentOS 2025年10月8日
  • CentOS 7安装及配置图解

    centos7的安装及主机名,进程改变,yum安装软件包组。 1.CentOS7的新特性及与6的改变: (1)身份管理:kerberos的跨平台信任机制:完全兼容微软活动目录 RE…

    CentOS 2025年6月8日
  • Linux下Ghost 博客系统安装教程

    先放出Ghost博客项目地址:https://github.com/tryghost/Ghost 前言 Ghost这个博客系统可真是难装,第一次装失败后放弃了一段时间,转而用的Ju…

    CentOS 2025年6月8日
  • CentOS中安装并使用Sendmail具体方法

    Sendmail作为一种免费的邮件服务器软件,已被广泛的应用于各种服务器中,它在稳定性、可移植性、及确保没有bug等方面具有一定的特色,且可以在网络中搜索到大量的使用资料,下面为大…

    CentOS 2025年7月7日
  • CentOS 6.9 minimal版系统安装图形化界面

    有时我们会用到图形化界面来操作,下面介绍是在虚拟机上安装centos 6.9 minimal版安装图形化界面(其他系统版本都类似吧,,,),如果是在物理机上安装进入的话要用的远程桌…

    CentOS 2025年6月13日
  • CentOS 7下DNS主从服务搭建及问题故障排错

    一、Linux环境 centos 7 主:192.168.3.173 从:92.168.3.172 二、都需要安装bind 服务安装包 配置主DNS服务器 主:/etc/named…

    CentOS 2025年6月9日
  • shell脚本切割Tomcat的日志文件

    鉴于在调试logback和log4j的文件切割一直无法成功,随性用shell写个脚本用来切割tomcat下的日志文件(大家如果有在logback或log4j使用文件切割成功的话,可…

    CentOS 2025年6月8日

发表回复

登录后才能评论