ssh批量管理 批量执行命令
-
pssh
2020-01-05 09:36:25pssh pssh [OPTIONS] command […] –version:查看版本 -h:主机文件列表,内容格式”[user@]host[:port]” -H:主机字符串,内容格式”[user@]host[:port]” -l:登录使用的用户名 -p:并发的线程数【可选】 -o:...远程的服务器群不建议设置同样的密码,最好做ssh无密码验证
pssh
pssh [OPTIONS] command […]
–version:查看版本 -h:主机文件列表,内容格式”[user@]host[:port]” -H:主机字符串,内容格式”[user@]host[:port]” -l:登录使用的用户名 -p:并发的线程数【可选】 -o:标准输出信息文件保存的目录【可选】 -e:错误输出信息文件保存的目录【可选】 -t:TIMEOUT 超时时间设置,0无限制【可选】 -O:SSH的选项 -v:详细模式 -A:手动输入密码模式 //需要所有主机密码相同,不推荐使用,最好做无密码验证 -x:额外的命令行参数使用空白符号,引号,反斜线处理 -X:额外的命令行参数,单个参数模式,同-x -i:将服务器执行命令的结果输出到当前终端 -P:打印出服务器返回信息 常用选项:-H 、-h 、-i
例:
pssh -H 'root@172.18.30.254 root@172.18.30.253' -i sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config # -H指定主机(可用单引号指定多台主机) -i表示在本地输出执行的结果 sed为要发送的命令
pssh -h ip.txt -i useradd "dc" #为ip.txt文件中的所有主机创建用户dc并显示执行结果,如果要调用远程的变量,那么需要把需要在远程主机执行的命令用单引号引起来,否则调用的是本地的变量
pssh -h ip.txt -i echo '$HOSTNAME' #如果要使用基于密码的方式去连接主机可以加-A选项,但是这个工具只会提示输入一次密码,也就是说,在批量执行的过程中,所有的主机密码都是相同的,在工作中,显然这样是不合要求的,所以这种方式一般是不使用的。
Pscp:将本地文件批量复制到远程主机
pscp.pssh -h ip.txt /root/ip.txt ~/ #将/root/ip.txt发送到ip.txt文件中的主机的家目录下 -v 显示复制过程 -a 复制过程中保留常规属性 -r 递归复制目录
pslurp:将远程主机的文件批量复制到本地
pslurp -h ip.txt -L /app/ /etc/passwd passwd #将所有ip.txt内的远程主机的/etc/passwd文件下载到本地的app路径下的对应ip下,文件名为passwd,最后的passwd为指定文件名(必须有该项,否则报错) pslurp -h ip.txt -L /tmp -r /home/student dc #将所有ip.txt内的主机的/home/student目录复制到本地的tmp目录下,并更改目录名为dc -L 指定从远程主机下载到本机的存储的目录 -r 递归复制目录
pnuke:远程杀死进程
选项与pssh基本一致
pnuke -H ip地址 进程名
-
PSSH
2015-07-21 14:36:02ssh批量管理 批量执行命令 转载于:https://blog.51cto.com/0x007/1676722转载于:https://blog.51cto.com/0x007/1676722
-
安装pssh
2019-08-07 20:48:49安装pssh 在centos7上安装pssh wget http://www.theether.org/pssh/pssh-1.4.3.tar.gz tar -xzf pssh-1.4.3.tar.gz cd pssh-1.4.3 python setup.py install 安装成功 -
【pssh】PSSH批量远程管理主机
2020-09-01 22:06:36【pssh】PSSH批量远程管理主机pssh介绍
pssh是python写的可以并发在多台机器上批量执行命令的工具,它的用法可以媲美ansible的一些简单用法,执行起来速度比ansible快它支持文件并行复制,远程命令执行,杀掉远程主机上的进程等等。杀手锏是文件并行复制,当需要在远程主机批量上传下载的时候,最好使用它。
pssh的使用
在使用pssh之前,必须要保证管理主机和本地主机进行过密钥的认证,或者是在进行批量时,没有做过密钥认证,但是必须保证被管理的多台主机的密码相同。关于如何做密钥认证,这里就不多说了,可以自行百度。
安装
官网下载地址:PSSH Download
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/parallel-ssh/pssh-2.3.1.tar.gz tar -zxvf pssh-2.3.1.tar.gz cd pssh-2.3.1 python setup.py install 或者 yum install -y pssh
使用yum安装后,只能使用pssh,但是编译安装后会包括其他命令也安装了(pscp prsync pnuke pslurp)
- pssh:在远程多台主机上并行运行命令
- pscp :把文件并行复制到多台远程主机上
- prsync:使用rsync协议本地文件同步到远程多台主机上。
- pnuke:在远程多台主机上并行killall某一进程
- pslurp:把文件从远程多台主机上复制到本地主机上
pssh常用参数
pssh --help Usage: pssh [OPTIONS] command [...] Options: --version show program's version number and exit --help show this help message and exit -h HOST_FILE, --hosts=HOST_FILE hosts file (each line "[user@]host[:port]") -H HOST_STRING, --host=HOST_STRING additional host entries ("[user@]host[:port]") -l USER, --user=USER username (OPTIONAL) -p PAR, --par=PAR max number of parallel threads (OPTIONAL) -o OUTDIR, --outdir=OUTDIR output directory for stdout files (OPTIONAL) -e ERRDIR, --errdir=ERRDIR output directory for stderr files (OPTIONAL) -t TIMEOUT, --timeout=TIMEOUT timeout (secs) (0 = no timeout) per host (OPTIONAL) -O OPTION, --option=OPTION SSH option (OPTIONAL) -v, --verbose turn on warning and diagnostic messages (OPTIONAL) -A, --askpass Ask for a password (OPTIONAL) -x ARGS, --extra-args=ARGS Extra command-line arguments, with processing for spaces, quotes, and backslashes -X ARG, --extra-arg=ARG Extra command-line argument -i, --inline inline aggregated output and error for each server --inline-stdout inline standard output for each server -I, --send-input read from standard input and send as input to ssh -P, --print print output as we get it Example: pssh -h hosts.txt -l irb2 -o /tmp/foo uptime
具体常用介绍:
- -h HOST_FILE 后边跟远程主机列表(ip)
- -H HOST_STRING 后边跟远程主机名或者ip地址
- -l USER 指定远程主机的用户名
- -p PAR 指定pssh最大的并行线程数。
- -o 将输出的内容重定向到一个指定的文件中
- -O 指定ssh参数的具体配置
- -e 将执行错误重定向到一个指定的文件中
- -t 设定命令执行超时时间
- -x 传递ssh命令的一些参数
- -i 在远程主机上执行命令完成后显示标准输出和标准错误
- -P 在执行远程命令时,输出执行结果
用法实例:
pssh -P -i -h sz_vpc.txt "w"
pscp拷贝文件到远程主机
pscp -h ip.txt /etc/wenjian.txt /tmp/
pnuke杀掉某一进程
这个命令类似yu killall命令
pnuke -h iplist.txt httpd
上边的意思是在远程主机上批量关闭httpd服务
能通过killall关闭的服务,都可以通过pnuke来批量完成
pslurp 远程主机拷贝文件到本地主机
pslurp -h iplist.txt -L /home/ /hose/wenjian/yuanc.conf open.conf
上边是,将所有远程主机/hose/wenjian/yuanc.conf复制到本地主机/home/目录下,并且重新命名为open.conf -L 来指定本地文件路径
下面这个是拷贝目录
pslurp -h iplist.txt -r -L /home/ /hose/wenjian/ open
PS:建议分发文件,执行命令,批量杀死进程,使用pssh,pscp,pnuke,速度很快的
-
PSSH用法
2020-06-07 15:39:25PSSH用法PSSH选项用法 PSSH 选项 –version:查看版本 -h:主机文件列表,内容格式”[user@]host[:port]” -H:主机字符串,内容格式”[user@]host[:port]” -A:手动输入密码模式 -i:每个服务器内部处理信息输出 -... -
PR PSSH Error
2020-11-28 23:00:28<div><p>Most encoders like Bento4, WOWZA, UnifiedStreaming and others make the PlayReady PSSH data (Wm Header) from the Key KID and PR LAURL. <p>Why does this need us to manually make the PR PSSH? Can... -
实用命令pssh pscp.pssh pslurp
2019-09-18 06:49:59pssh包是在epel源里面的pssh命令在使用时要实现两台机器间的基于秘钥的ssh登陆,因为该命令是无法交互输入yes的,而且在使用-A手动输入... 其中-e 和 -o参数也是比较常用的pscp.pssh 和pssh工具来自同一个包,他可... -
PSSH命令
2020-12-07 22:25:20pssh 在多个主机上并行地运行命令 -h 执行命令的远程主机列表,文件内容格式[user@]host[:port] 如 test@172.16.10.10:229 -H 执行命令主机,主机格式 user@ip:port -l 远程机器的用户名 -p 一次最大允许多少连接 -P ... -
pssh 2.1 broken
2020-12-08 21:39:081. pssh -h hosts.txt -l root -i uptime What is the expected output? [darose ~]$ pssh -h code/admin/nagios/config/primary/demdex/demdex-hosts.txt -l root -i uptime [1] 11:33:27 [SUCCESS] <server&... -
PSSH使用
2018-01-09 17:31:21一、PSSH的安装1.首先需要配置节点之间的SSH,然后在其中一个节点上安装2.安装epelyum-yinstallepel-release3.安装pssh[root@slave1~]#yum-yinstallpssh二、PSSH的使用1.常用参数-h:主机文件列表,内容格式”[user@... -
pssh基础
2017-08-04 21:09:08centos安装psshyum install python-pippip install pssh 用途 pssh 在多个主机上并行地运行命令。 pscp 把文件并行地复制到多个主机上。 prsync 通过 rsync 协议把文件高效地并行复制到多个主机上。 pslurp 把... -
pssh ignores stderr
2020-12-09 06:11:33pssh collects stdout (with --print option) and ignores stderr, whereas stderr is the important thing: all errors are printed there. </code></pre> <p>Original issue reported on code.google.... -
pssh使用简介
2020-07-10 15:41:57pssh简介 pssh全称是parallel-ssh,它是基于Python编写的并发在多台服务器上批量执行命令的工具。它支持文件并行复制、远程和并行执行命令,并且可以杀掉远程主机的进程等。它的功能与ansible差不多,但是它是一个... -
centos安装pssh
2020-04-08 17:09:321、使用CentOS yum源(安装的是最新版的,我安装的是2.7.5) yum install python* 2、下载pass的压缩包 网站是http://www.theether.org/pssh/ ...[root@szlnmp01 tmp]# tar -zxvf pssh-1.4.3... -
PSSH not found
2020-12-01 15:40:35<p>Could not extract license from video stream (PSSH not found) <p>I think in this case, the PSSH is returned in the license request json response. But, this fails before every trying to get the ... -
使用PSSH批量管理Linux服务器
2020-09-15 02:54:56pssh是python开发的一个用来批量管理linux主机的工具,现在我们来介绍pssh的使用方法。 -
pssh needs man pages
2020-12-09 06:12:04t any man pages for pssh, prsync, etc. This would be very useful for users (and forgetful developers). </code></pre> <p>Original issue reported on code.google.... -
pssh命令详解
2019-02-19 22:09:00基础命令学习目录首页 ... pssh提供OpenSSH和相关工具的并行版本。包括pssh,pscp,prsync,pnuke和pslurp。该项目包括psshlib,可以...pssh是python写的可以并发在多台机器上批量执行命令的工具,它的用法可以媲美a...
收藏数
892
精华内容
356