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日

相关推荐

  • CentOS 6.5安装Python2.7.14

    在centos 6.5下安装python2.7.14过程。 查看当前系统中的 Python 版本 python –version  python -…

    CentOS 2025年6月11日
  • CentOS 6.5安装MySQL 5.6.10及安全配置

    注:以下所有操作均在centos 6.5 x86_64位系统下完成。 #准备工作# 在安装mysql之前,请确保已经使用yum安装了各类基础组件,具体见下面的《CentOS安装LN…

    CentOS 2025年6月15日
  • CentOS中的环境变量配置文件

    centos的环境变量配置文件体系是一个层级体系,这与其他多用户应用系统配置文件是类似的,有全局的,有用户的,有shell的,另外不同层级有时类似继承关系。下面以PATH变量为例。…

    CentOS 2025年6月20日
  • CentOS 7下使用docker-compose部署Django与MySQL实战

    背景: 本萌最近在部署自己开发的项目的时候发现同一套代码上传到服务器上后,部分功能莫名其妙的有点问题,服务器的各项配置都没有做过变动,所以想把项目转战到docker。 奈何刚接触d…

    CentOS 2025年9月21日
  • 基于Linux(CentOS)的SVN环境搭建

    基于Linux(CentOS)的SVN环境搭建 1. 安装svn yum intall subversion 2. 查看安装位置 rpm -ql subversion 3. 检验s…

    CentOS 2025年9月24日
  • 以单用户模式启动 CentOS/RHEL 7/8 的三种方法

    单用户模式,也被称为维护模式,超级用户可以在此模式下恢复/修复系统问题。 通常情况下,这类问题在多用户环境中修复不了。系统可以启动但功能不能正常运行或者你登录不了系统。 在基于 R…

    CentOS 2025年10月21日
  • CentOS 6.8内核版本升级

    centos 6.8内核版本升级 1.查看当前版本 CentOS release 6.8 (Final) Kernel \r on an \m 2.升级CentOS 3.内核升级至…

    CentOS 2025年6月13日
  • CentOS 7下Redis5集群的搭建和使用

    1、简要说明 Redis5.0版是Redis产品的重大版本发布,推出了各种新特性,其中一点是放弃 Ruby的集群方式,改为 使用 C语言编写的 redis-cli的方式,是集群的构…

    CentOS 2025年6月24日
  • 在 CentOS7 上部署 MySQL 主从

    在 centos7 上部署 mysql 主从 1 通过 SecureCRT 连接至 MySQL 主服务器; 2 找到 my.cnf 文件所在的目录:    my…

    CentOS 2025年6月13日
  • Centos中部署并加密FTP服务器

    FTP是一种上传和下载用的软件。用户可以通过它把自己的PC机与运行FTP协议的服务器相连,访问服务器上的程序和信息,本篇文章重点为大家分享如何在Centos中部署并加密FTP服务器…

    CentOS 2025年6月8日

发表回复

登录后才能评论