複数サーバ コマンド実行

(22)

前提: 接続先に鍵登録済

sudo apt -y install pdsh

pdsh -L

export PDSH_RCMD_TYPE='ssh'

pdsh -w 192.168.137.182,192.168.137.169 'id;uname -n'

pdsh -w 192.168.137.[182,169] 'id;uname -n'

pdsh -w 192.168.137.[182,169] 'id;uname -n' | dshbak -c

(12)

前提: 接続先に鍵登録済

apt -y install pdsh

pdsh -L

export PDSH_RCMD_TYPE='ssh'

pdsh -w 192.168.137.180,192.168.137.187 'id;uname -n;cat /etc/os-release'

pdsh -w 192.168.137.18[0,7] 'id;uname -n;cat /etc/os-release'

pdsh -w 192.168.137.18[0,7]  'id;uname -n;cat /etc/os-release' | dshbak -c

 

(RL9)
https://zoo200.net/linux-command-pdsh-pdcp/

前提: 接続先に鍵登録済

dnf -y install epel-release
dnf search pdsh
dnf -y install pdsh pdsh-rcmd-ssh


pdsh -L

export PDSH_RCMD_TYPE='ssh'


pdsh -w 192.168.137.191,192.168.137.192 'id;uname -n'

pdsh -w 192.168.137.19[1-2] 'id;uname -n'

pdsh -w 192.168.137.19[1-2] 'id;uname -n' | dshbak -c

 

(2022)

https://learn.microsoft.com/ja-jp/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-7.4

https://qiita.com/awsmgs/items/8ceea2bf2d47486805f1#:~:text=%E7%AE%A1%E7%90%86%E8%80%85%E6%A8%A9%E9%99%90%E3%81%A7PowerShell%E3%82%92%E9%96%8B%E3%81%8F%201%201.%20PowerShell%E3%82%92%E9%96%8B%E3%81%8F%EF%BC%88%E7%AE%A1%E7%90%86%E8%80%85%E6%A8%A9%E9%99%90%E3%81%A7%E3%81%AA%E3%81%8F%E3%81%A6OK%EF%BC%89%202%202.%20WinRM%E3%82%92%E6%9C%89%E5%8A%B9%E3%81%AB%E3%81%99%E3%82%8B%20%E6%93%8D%E4%BD%9C%E3%81%95%E3%82%8C%E3%82%8B%E5%81%B4%E3%81%A8%E3%81%AF%E7%95%B0%E3%81%AA%E3%82%8B%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%82%92%E5%AE%9F%E8%A1%8C%E3%81%97%E3%81%BE%E3%81%99,3.%20%E6%93%8D%E4%BD%9C%E3%81%95%E3%82%8C%E3%82%8B%E5%81%B4%E3%81%AEIP%E3%82%92%E4%BF%A1%E9%A0%BC%E3%81%A7%E3%81%8D%E3%82%8B%E3%83%9B%E3%82%B9%E3%83%88%E3%81%A8%E3%81%97%E3%81%A6%E7%99%BB%E9%8C%B2%E3%81%99%E3%82%8B%20TrustedHosts%E3%81%AB%E7%99%BB%E9%8C%B2%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%20Set-Item%20WSMan%3A%5Clocalhost%5CClient%5CTrustedHosts%20-Value%20%22%E6%93%8D%E4%BD%9C%E3%81%95%E3%82%8C%E3%82%8B%E5%81%B4%E3%81%AEIP%22%20


前提: 
-- 接続される側
管理者権限でPowerShellを開く
Enable-PSRemoting
New-PSSession


-- 接続する側
管理者権限でPowerShellを開く
net start WinRM
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.137.62,192.168.137.63"

 

Invoke-Command -ComputerName 192.168.137.62,192.168.137.63 -ScriptBlock {whoami;ipconfig}