首页 > 系统相关 >Linux pssh安装与使用

Linux pssh安装与使用

时间:2022-09-25 20:34:53浏览次数:41  
标签:pssh 安装 192.168 ansible ssh Linux libin root

Linux pssh安装与使用

说明:我这是没有在密钥认证的情况下操作

1、安装pssh

[root@libin ansible]# yum install -y pssh

[root@libin ansible]# rpm -ql pssh
/usr/bin/pnuke
/usr/bin/prsync
/usr/bin/pscp
/usr/bin/pslurp
/usr/bin/pssh
/usr/bin/pssh-askpass

2、使用pssh

[root@libin ansible]# man pssh

[root@libin ansible]# cat hosts.txt
192.168.124.134
192.168.124.132

[root@libin ansible]# pssh -h hosts.txt hostname
[1] 19:13:21 [SUCCESS] 192.168.124.132
[2] 19:13:21 [SUCCESS] 192.168.124.134

[root@libin ansible]# pssh -h hosts.txt "hostname > /tmp/libin.txt"            #追加到 /tmp/libin.txt
[1] 19:16:32 [SUCCESS] 192.168.124.132
[2] 19:16:32 [SUCCESS] 192.168.124.134

[root@libin ansible]# cat /tmp/libin.txt
libin.com

-i:执行命令时,将标准错误的和标准输出的信息都显示出来

-p:同一时间并发去执行命令,指定最大的并发数量

-A:输入用户的密码

[1] 19:38:32 [SUCCESS] 192.168.124.134
wlcome to study redhat-linux
libin3.com
[2] 19:38:32 [SUCCESS] 192.168.124.132
libin.com

[root@libin ansible]# pssh -A -ih hosts.txt  ls -l /tmp/   

 

3、使用pscp

[root@libin ansible]# pscp -h hosts.txt /etc/hosts /tmp/          #将客户端的/etc/hosts拷贝到/tmp/下
[1] 19:43:36 [FAILURE] 192.168.124.134 Exited with error code 1
[2] 19:43:36 [SUCCESS] 192.168.124.132

[root@libin ansible]# pssh -h hosts.txt ls -l /tmp/
[1] 19:45:19 [SUCCESS] 192.168.124.132
[2] 19:45:19 [SUCCESS] 192.168.124.134

[root@libin ansible]# pssh -ih hosts.txt ls -l /tmp/      #查看/tmp/目录下的所有文件

 =========================================

批量管理:ssh秘钥认证:(免密码登录 互信,私钥(钥匙)和公钥(锁头))

(1)把公钥发到服务器

在一台机器上可用管理和控制其他机器

secureCRT /xshell/ssh秘钥认证/pssh

1、创建公钥

[root@libin ansible]# ssh-keygen                                        #(默认为RSA类型,已经比较过时)

[root@libin ansible]# ssh-keygen -t dsa                               #-t:指定类型
Generating public/private dsa key pair.                                #生成一对公钥,私钥
Enter file in which to save the key (/root/.ssh/id_dsa):         私钥位置            #默认存放的目录为/root/.ssh/id_dsa,ll -a 查看所有隐藏的文件

Enter passphrase (empty for no passphrase):                     设置密码

Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
SHA256:yQiMcqnRlhBguTI5uApgP8hv+z2upk6/eXmbHZSNFvI [email protected]
The key's randomart image is:
+---[DSA 1024]----+
|=o. |
|.+ = |
|+.O o . . |
|BO . o .o = |
|*+o . S E . |
|oo o o |
|o ... . . |
|. .o..o+ .o . |
| o+=*=ooo.. |
+----[SHA256]-----+

[root@libin ansible]# ll /root/.ssh/
总用量 24
-r--------. 1 root root 1584 2月 22 2022 authorized_keys
-rw------- 1 root root 668 9月 25 20:10 id_dsa
-rw-r--r-- 1 root root 604 9月 25 20:10 id_dsa.pub

 2、发送公钥到各个服务器

[root@libin ansible]# ssh-copy-id -i /root/.ssh/id_dsa.pub [email protected]            #-i:指定公钥位置  ,-f 强制

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_dsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

[root@libin ansible]# ssh 192.168.124.134 hostname                                                       #连接服务器执行一个命令,检查
Warning: Permanently added '192.168.124.134' (ECDSA) to the list of known hosts.
wlcome to study redhat-linux
libin3.com

================================================================

 

标签:pssh,安装,192.168,ansible,ssh,Linux,libin,root
From: https://www.cnblogs.com/libin-linux/p/16728650.html

相关文章

  • 弃用 Windows,政府机构 5000 万台电脑将替换为国产 Linux!
    来源:https://www.linuxmi.com/50-million-pc-linux.html开源社区的一大胜利!继德国之后,中国现在想在5000万台PC上抛弃Windows并运行Linux!如果您一直密切关注Lin......
  • Linux错题集1
    错题1在Linux系统中,小王希望将他执行ls命令的输出结果保存在当前目录下的文件output.ls中,以供日后进行分析和使用,但要求不覆盖原文件的内容,他应该使用的命令是A.ls>outpu......
  • 在Linux下的文件IO的使用(一)
    系统调用系统调用:操作系统提供给用户程序调用的一组“特殊”接口,用户程序可以通过这组“特殊”接口来获得操作系统内核提供的服务为什么用户程序不能直接访问系......
  • Anaconda新安装后配置环境遇到的一些问题及解决方案
    问题一:condaupgradeconda报错URL错误结局方案:换源,正确指令如下condaconfig--addchannelshttp://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/conda......
  • Mongo安装及基本命令
    一、MongoDB介绍MongoDB是一个基于分布式文件存储的数据库。由C++语言编写,其将数据存储为一个文档,数据结构由键值对形式表示,文档型类似json对象,字段值可以包含其他文档,......
  • 记录黑苹果OpenCore 安装-v跑码结束显示logo、进度条、光标,但不进入系统问题
    型号:Dell Inspiron15-3559    核显:HD520OS版本: macOSCatalina10.15.6(19G2021) 问题-v模式启动,跑码结束,显示苹果logo和进度条,鼠标光标正常显示,连......
  • Linux学习(一)从搭建自己的code-server开始
    前言某天碰巧看到了网页版的VSCode,发现居然有这种好东西,浏览器访问https://vscode.dev/,ipad终于能当生产力工具而不是爱奇艺播放器了o.O其实这个东西已经够用了,代码......
  • 批量安装包
      写进requirement.txt里面 然后pip-rrequirement.txt  里面长这样:    ......
  • Excalidraw:开源实用的白板画图工具(在线/本地安装)
    Excalidraw是一款开源的画图工具,可以画一些简单的流程图,显示效果像是用笔在纸上画的一样,操作简单明了,可以在线使用或者通过谷歌浏览器插件安装在本地。在线使用网址:Excal......
  • Unix/Linux系统编程学习笔记-4
    笔记第七章文件操作文件操作级别文件操作分为五个级别,按照从低到高的顺序排列如下。(1)硬件级别:fdisk:将硬盘、U盘或SDC盘分区。mkfs:格式化磁盘分区,为系统做好......