一,安装dsh
wget http://www.netfort.gr.jp/~dancer/software/downloads/libdshconfig-0.20.9.tar.gztar xvf libdshconfig-0.20.9.tar.gzcd libdshconfig-0.20.9./configure --prefix=/usr/make && make installwget http://www.netfort.gr.jp/~dancer/software/downloads/dsh-0.25.9.tar.gztar xvf dsh-0.25.9.tar.gzcd dsh-0.25.9./configure --prefix=/usr/make && make installldconfig[root@heit]# dsh --helpDistributed Shell / Dancer's shell version 0.25.9 Copyright 2001-2005 Junichi Uekawa, distributed under the terms and conditions of GPL version 2-v --verbose Verbose output-q --quiet Quiet-M --show-machine-names Prepend the host name on output-H --hide-machine-names Do not prepend host name on output-i --duplicate-input Duplicate input given to dsh-b --bufsize Change buffer size used in input duplication-m --machine [machinename] Execute on machine-n --num-topology How to divide the machines-a --all Execute on all machines-g --group [groupname] Execute on group member-f --file [file] Use the file as list of machines-r --remoteshell [shellname] Execute using shell (rsh/ssh)-o --remoteshellopt [option] Option to give to shell -h --help Give out this message-w --wait-shell Sequentially execute shell-c --concurrent-shell Execute shell concurrently-F --forklimit [fork limit] Concurrent with limit on number-V --version Give out version information这说明安装成功ssh-keygen -t rsa一路回车会在/root/.ssh/目录下生成公钥(id_rsa.pub)和私钥(id_rsa)。将id_rsa.pub复制到被控制端/root/.ssh/目录下mv id_rsa.pub authorized_keyschmod authorized_keys 600在控制端mkdir /root/.dsh/mkdir /root/.dsh/group/touch /root/.dsh/machines.listtouch /root/.dsh/group/g1cat //root/.dsh/machines.list192.168.220.12cat /root/.dsh/group/g1192.168.220.12dsh -r ssh -a touch /root/adsh -r ssh -g g1 touch /root/a如果远端机器修改了端口号
dsh -M -a -r ssh -o -p9830 touch /tmp/li