Linux dsh工具安装

First and foremost, you need to install dsh. The downloads page for the project is a nightmare (http://www.netfort.gr.jp/~dancer/software/downloads/list.cgi), but you basically want the latest version of libdshconfig and dsh. At the time of this writing, that would be 0.20.13 and 0.25.9 respectively.

I just dropped them into /tmp for the time being:

cd /tmp
wget http://www.netfort.gr.jp/~dancer/software/downloads/libdshconfig-0.20.13.tar.gz
wget http://www.netfort.gr.jp/~dancer/software/downloads/dsh-0.25.9.tar.gz

Then go through the normal install from source process, starting with libdshconfig

cd /tmp
tar -zxvf libdshconfig-0.20.13.tar.gz
cd libdshconfig-0.20.13
./configure
make
sudo make install
cd /tmp
tar -zxvf dsh-0.25.9.tar.gz
 cd dsh-0.25.9
 ./configure
 make
 sudo make install

now you should be able to run dsh and have it return an error that no machine was specified:

josh.prewitt$ dsh
dsh: no machine specified

Configuring DSH

You will want to setup RSA keys for your user on each of the machines that you want to log in to remotely so that you are not prompted for a password. (This is outside the scope of this article, there are about a gazillion different articles online that will teach that). Once the keys are in place, you will want to create group files. You will need to mkdir -p ~/.dsh/group and then create a text file in the group directory that lists the machines you want to connect to. Here is an example:

josh.prewitt$ pwd
/Users/josh.prewitt/.dsh/group
josh.prewitt$ cat web 
josh@server1.mywebsite.com
josh@server2.mywebsite.com
josh@server3.mywebsite.com

This sets the user and the host that you want in the “web” group.

Next up is a very important configuration change. dsh wants to use rsh by default instead of ssh. You will need to edit /usr/local/etc/dsh.conf as an Administrator to change that. Just change the line:

remoteshell =rsh

to read:

remoteshell =ssh

Save the file, and you are ready to go.

Actually using DSH

Ok, now for the magic. Assuming you have a group named ‘web’, you could run:

dsh -c -g web -M 'uname -a'

This will return the results of uname -a for each server. The -c flag does it concurrently instead of going to each machine one at a time. The -M flag tells it to list the machine name by the response.

Other stuff

I prefer to always see the machine name, so instead of always specifying -M, I created a new file at ~/,dsh/dsh.conf and included the line “showmachinenames=1″. You can set other options here too. For example, say you use a non standard ssh port. You could specify on the command line with -o:

dsh -c -g web -o "-p 2222" 'uname -a'

OR, you can set dsh to always use a different port by adding the line “remoteshellopt=-p 2222″ to your configuration file.

Other sources if my article didn’t make sense:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值