溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

輕量級自動化運維工具pssh與pslurp

發(fā)布時間:2020-08-11 15:11:03 來源:ITPUB博客 閱讀:195 作者:大雄45 欄目:建站服務(wù)器
pssh項目

項目:http://code.google.com/p/parallel-ssh/

語法:

Usage: pscp.pssh [OPTIONS] local remote

常用選項:

--version:查看版本
-h:主機文件列表,內(nèi)容格式”[user@]host[:port]”
-H:主機字符串,內(nèi)容格式”[user@]host[:port]”
-A:手動輸入密碼模式
-i:每個服務(wù)器內(nèi)部處理信息輸出
-l:登錄使用的用戶名
-p:并發(fā)的線程數(shù)【可選】
-o:標(biāo)準(zhǔn)輸出文件的輸出目錄(可選)
-e:標(biāo)準(zhǔn)錯誤文件的輸出目錄(可選)
-t:TIMEOUT 超時時間設(shè)置,0無限制【可選】
-O:SSH的選項
-P:打印出服務(wù)器返回信息
-v:詳細(xì)模式

【例1】通過pssh批量向主機文件列表中的主機執(zhí)行echo "hello pssh"。

[root@CentOS7 ~]# cat host.txt 
172.20.200.200
192.168.8.61
[root@CentOS7 ~]# pssh -h host.txt -i echo "hello pssh"
[1] 16:31:10 [SUCCESS] 192.168.8.61
hello pssh
[2] 16:31:10 [SUCCESS] 172.20.200.200
hello pssh

注:當(dāng)不支持ssh的key認(rèn)證時,可通過-A選項,手動輸入密碼認(rèn)證批量執(zhí)行指令。

【例2】將標(biāo)準(zhǔn)錯誤和標(biāo)準(zhǔn)正確重定向都保存至本地主機的/app目錄下。

[root@CentOS7 ~]# pssh -h host.txt  -o /app/ -e /app/ -i echo "hello pssh"
[1] 16:52:32 [SUCCESS] 192.168.8.61
hello pssh
[2] 16:52:32 [SUCCESS] 172.20.200.200
hello pssh
[root@CentOS7 ~]# ls /app/
172.20.200.200  192.168.8.61
[root@CentOS7 ~]# cat /app/192.168.8.61 
hello pssh
pscp.pssh 命令

功能:將本地文件批量復(fù)制到遠(yuǎn)程主機
語法:

[root@CentOS7 ~]# pscp.pssh --help
Usage: pscp.pssh [OPTIONS] local remote

選項:基本與pssh 命令一致,不過有個-r選項可以遞歸復(fù)制目錄

【例1】將本地/etc/fstab文件批量復(fù)制到主機列表文件中的主機的/app目錄下

[root@CentOS7 ~]# pscp.pssh -h host.txt /etc/fstab /app/
[1] 17:19:32 [SUCCESS] 192.168.8.61
[2] 17:19:32 [SUCCESS] 172.20.200.200
[root@CentOS7 ~]# pssh -h host.txt -i ls /app/ -l
[1] 17:25:14 [SUCCESS] 192.168.8.61
total 4
-rw-r--r-- 1 root root 595 Nov  8 20:27 fstab
[2] 17:25:14 [SUCCESS] 172.20.200.200
total 4
-rw-r--r-- 1 root root 595 Nov  9 17:19 fstab

【例2】將本地目錄/test/批量復(fù)制到主機文件列表中的主機的/app目錄

[root@CentOS7 ~]# pscp.pssh -h host.txt -r /test/ /app/
[1] 17:23:14 [SUCCESS] 192.168.8.61
[2] 17:23:14 [SUCCESS] 172.20.200.200
[root@CentOS7 ~]# pssh -h host.txt -i ls /app/ -l
[1] 17:26:33 [SUCCESS] 192.168.8.61
total 8
-rw-r--r-- 1 root root  595 Nov  8 20:27 fstab
drwxr-xr-x 2 root root 4096 Nov  8 20:33 test
[2] 17:26:33 [SUCCESS] 172.20.200.200
total 4
-rw-r--r-- 1 root root 595 Nov  9 17:19 fstab
drwxr-xr-x 2 root root  48 Nov  9 17:25 test
pslurp命令

功能:將遠(yuǎn)程主機的文件批量復(fù)制到本地,與pscp.pssh命令功能相反。
語法:

pslurp  [-vAr]  [-h hosts_file] [-H [user@]host[:port]] [-l user] [-p par] [-o outdir] [-e errdir] [-t timeout]  [-O  options]  [-xargs] [-X arg] [-L localdir] remote local(本地名)

選項:

-L 將文件從遠(yuǎn)程主機復(fù)制到給定的本地目錄,local是下載到本地后的名稱

【例】批量下載目標(biāo)服務(wù)器的passwd文件至本地目錄/app下,并更名為user

[root@CentOS7 ~]# pslurp -h host.txt -L /app/ /etc/passwd user
[1] 17:35:38 [SUCCESS] 192.168.8.61
[2] 17:35:38 [SUCCESS] 172.20.200.200
[root@CentOS7 ~]# tree /app/
/app/
├── 172.20.200.200
│   └── user
└── 192.168.8.61
    └── user
2 directories, 2 files

原文來自: https://www.linuxprobe.com/pssh-pslurp-tool.html

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI