有一个叫做cssh for linux的工具,它与我想在Windows上使用的一样。 基本上我login到彼此相同的服务器,我希望能够在两个窗口同时input相同的东西来查看日志,做各种greps等。
PuTTY命令发件人是你正在寻找。
你总是可以通过CygWin (一个适用于Windows的UNIX兼容shell)来安装clusterssh …(你可以在google上获得关于这两者的更多信息)…
我知道这是一个古老的问题,但是我发现它是因为我已经使用了腻子命令发送器五年了,一直认为它非常糟糕。 到现在为止,我没有足够的去寻找替代品。 刚刚遇到puttyCluster – https://github.com/mingbowan/puttyCluster – 和圣洁,这是不真实的,我一直在愚蠢的腻子CS浪费时间,它无法使用最大化+“停靠”的窗口。
还发现这些替代品,但没有尝试过:cputty clustershish(我没有代表发表更多的链接,但只是谷歌他们)。
我最近想出一个方法来做到这一点很容易。 我用一个Excel工作表来build立cmd命令,包括putty sshlogin,然后复制一个cmd窗口中的列。 即使您必须为每个服务器自定义命令,它的工作方式也像魔术一样。
cmd Command ip user name password Command template echo /snmp set enabled=yes >temp\10.10.0.9.txt| putty -ssh [email protected] -pw passwd -m temp\10.10.0.9.txt 10.10.0.9 user_name passwd /snmp set enabled=yes echo /snmp set enabled=yes >temp\10.10.0.31.txt| putty -ssh [email protected] -pw passwd2 -m temp\10.10.0.31.txt 10.10.0.31 user_name2 passwd2 /snmp set enabled=yes
如果要在每台计算机上运行确切的命令列表,则将其保存到一个文件中,然后使用另一个工作表生成命令行批处理。
cmd Command ip user name password putty -ssh [email protected] -pw paaswd -m commands.txt 192.168.0.21 user_name paaswd putty -ssh [email protected] -pw paaswd -m commands.txt 192.168.0.22 user_name paaswd
您将需要在putty main文件夹中创build一个名为temp的文件夹,并且您可能需要自定义putty日志logging以保存每个ip或pear会话的文件。 这是我的第一篇文章,所以我不能上传图片。
除了使用clusterssh或mtputty之外,简单的bash脚本可以使用sshlogin到远程服务器列表,使用scp将每个文件复制到每个服务器,并在每个服务器上执行一个脚本。 我是一个bash脚本新手,所以可能不是最有效或最好的select,但似乎很容易pipe理。 我发现它比clusterssh和mtputty更容易。 将此代码保存到名为copyFileToServers.sh的文件中,创build一个具有ips或服务器名称列表的serverlist文件,并通过键入./copyFileToServers.sh执行。
你需要在windows上使用cygwin(这是我testing过的唯一的地方)。 你将不得不安装sshpass(我知道人们真的恨这个软件包,但我懒得得到所有的服务器上的SSH密钥),可以从sourceforge下载。
有一点需要注意,你必须使用ssh user@remomte_server从你的pipe理员机器的命令行login每台你想pipe理的服务器。 除非手动确认为远程服务器添加ssh密钥,否则sshpass不起作用。 你只需要做一次。
(注意:截至2014年7月,我无法在windows cygwin上运行clusterssh,因此我无法真正了解该程序在完成OP所要求的内容时的好坏。)
HOSTS=./serverlist echo "what file should be copied to the remote servers?" read file echo "where should the file be placed on each remote server?" read dest echo "what script should be run on all remote nodes?" read remoteScript while read line do if [ "${#file}" -gt 0 ] then sshpass -p 'password' scp $file root@$line:$dest else echo "skipping file copy" fi if [ "${#remoteScript}" -gt 0 ] then sshpass -p 'password' ssh root@$line 'bash -s' < $remoteScript else echo "skipping remoteScript execution" fi echo $line done < $HOSTS