Using DSH (Distributed Shell) to Run Linux Command

发布于 2015/11/20 16:27
字数 731
阅读 37
收藏 0
点赞 0
评论 0

DSH is short for “Distributed Shell” or “Dancer’s Shell” it is freely available on most major distributions of Linux, but can easily be built from source if your distribution does not offer it in its package repository. You can obtain the source at.

Install DSH (Distributed Shell) in Linux

We are going to assume a Debian / Ubuntu environment for the scope of this tutorial. If you are using another distribution, please substitute the appropriate commands for your package manager.

On Debian / Ubuntu

First, let’s install the package via apt:

$ sudo apt-get install dsh

On RHEL / CentOS / Fedora

This method is for those who are not using Debian, and want to compile it from source tar balls. First you need to compile “libdshconfig” and install.

# wget http://www.netfort.gr.jp/~dancer/software/downloads/libdshconfig-0.20.10.cvs.1.tar.gz
# tar xfz libdshconfig*.tar.gz 
# cd libdshconfig-*
# ./configure ; make
# make install

Then compile dsh and install.

# wget http://www.netfort.gr.jp/~dancer/software/downloads/dsh-0.22.0.tar.gz
# tar xfz dsh-0.22.0.tar.gz
# cd dsh-*
# ./configure ; make 
# make install

The main configuration file “/etc/dsh/dsh.conf” (For Debian) and “/usr/local/etc/dsh.conf” (for Red Hat) is pretty straightforward, but since rsh is an unencrypted protocol, we are going to use SSH as the remote shell. Using the text editor of your choice, find this line:

remoteshell =rsh

And change it to:

remoteshell =ssh

There are other options you can pass in here, if you choose to do so, and there are plenty of them to find on the dsh man page. For now, we are going to accept the defaults and have a look at the next file, /etc/dsh/machines.list (for Debian).

For Red Hat based systems you need to create a file called “machines.list” in “/usr/local/etc/” directory.

The syntax here is pretty easy. All one has to do is to enter in a machine’s credentials (Hostname, IP Address, or FQDN) one per line.

Note: When accessing more than one machine simultaneously, it would behove you to set up key-based password-less SSH on all of your machines. Not only does this provide ease of access, but security wise, it hardens your machine as well.

My “/etc/dsh/machines.list” or “/usr/local/etc/machines.list” file says:

Once you have entered in the credentials of the machines you wish to access, let’s run a simple command like uptime to all of the machines.

$ dsh –aM –c uptime
Sample Output 05:11:58 up 40 days, 51 min, 0 users, load average: 0.00, 0.01, 0.05 05:11:47 up 13 days, 38 min, 0 users, load average: 0.00, 0.01, 0.05

So what did this command do?

Pretty simple. First, we ran dsh and passed the “–a” option to it, which says to send the “uptime” command to “ALL” of the machines listed in “/etc/dsh/machines.list“.

Next, we specified the “–M” option, which says to return the “machine name” (specified in “/etc/dsh/machines.list“) along with the output of the uptime command. (Very useful for sorting when running a command on a number of machines.)

The “–c” option stands for “command to be executed” in this case, “uptime“.

DSH can also be configured with groups of machines in the “/etc/dsh/groups/” file, where is a file with a list of machines in the same format as the “/etc/dsh/machines.list” file. When running dsh on a group, specify the groupname after the “-g” option.

For Red Hat based systems you need to create a folder called “groups” in “/usr/local/etc/” directory. In that “groups” directory you create a file called “cluster“.

For example, run the “w” command on all machines listed in the “cluster” group file “/etc/dsh/groups/cluster” or “/usr/local/etc/groups/cluster“.

$ dsh –M –g cluster –c w

DSH provides much more flexibility, and this tutorial only scratches the surface. Aside from executing commands, DSH can be used to transfer files, install software, add routes, and much more.

To a Systems Administrator tasked with the responsibility of a large network, it is invaluable.


共有 人打赏支持


粉丝 26
博文 46
码字总数 13191
作品 0


ToSun ⋅ 2015/09/20 ⋅ 0

Docker入门教程 Part 4 Swarms

前言 本篇笔记是官方Get Started入门教程的Part 4,主要介绍 Docker 集群 Swarm 的功能和使用。前面章节都是在单主机上使用Docker,这个章节将学会在集群中使用Docker容器。 我正在学习Docke...

iotisan ⋅ 2017/11/16 ⋅ 0

Install Htop 2.0 – Linux Process Monitoring for RHEL, CentOS & Fedora

原文:https://www.tecmint.com/install-htop-linux-process-monitoring-for-rhel-centos-fedora/ This article is the continuation of our Linux system monitoring series, today we’re ......

zdhsoft ⋅ 03/27 ⋅ 0

voltdb run sql file---run script files

Script files — You can run multiple queries or stored procedures in a single command using the file directive. The file directive takes a text file as an argument and executes......

Oscarfff ⋅ 2016/08/19 ⋅ 0


Copyright © ARK Game Website: https://arkgame.net Github: https://github.com/ArkGame/ArkGameFrame Gitee(码云): https://gitee.com/ArkGame/ArkGameFrame ArkGameFrame ArkGameFrame......

ArkGame ⋅ 2017/09/18 ⋅ 0


Python Programming Guide The Spark Python API (PySpark) exposes the Spark programming model to Python. To learn the basics of Spark, we recommend reading through theScala progra......

openthings ⋅ 2016/03/09 ⋅ 0

Android : First step – Download and build

This document provides a wiki for setting up a local environment on Linux Ubuntu to work on Android source code. 1. Getting Android source code a. Prerequisites : Android build ......

我是一只鱼 ⋅ 2011/09/02 ⋅ 0

Linux Netcat command – The swiss army knife of net

Swiss Army Knife of networking netcat is a versatile tool that is able to read and write data across TCP and UDP network . Combined with other tools and redirection it can be us......

杨尚川 ⋅ 2015/02/11 ⋅ 0


文章来自:互联网 答案本人愚见   1. How many memory layers are in the shared pool?  Answer: 1 1.libary cache 2.dictionary cache2 libary cache contain 1.shared sql area 2.pr......

张玉涛 ⋅ 2012/03/16 ⋅ 0

Effective Shell Part 3: Getting Help

This is the third part of my Effective Shell series - practical examples of ways to be more efficient with everyday tasks in a shell. Part 1: Navigating the Command Line Part 2:......

Dave Kerr ⋅ 2017/12/19 ⋅ 0






前台:encodeURI(sbzt) 后台:String param = URLDecoder.decode(sbzt,"UTF-8");

west_coast ⋅ 昨天 ⋅ 0


前言 我是上学期学的汇编,因为有vs又不想用课上教的麻烦的dosbox以及masm32,但是一直没找到高亮插件和能调试的(难在运行不了而找不到答案上,出现的错误在最后放出,还请先达们不吝指点)...

simpower ⋅ 昨天 ⋅ 0


node 模块机制 前言 说到node,就不免得提到JavaScript。JavaScript自诞生以来,经历了工具类库、组件库、前端框架、前端应用的变迁。通过无数开发人员的努力,JavaScript不断被类聚和抽象,...

小草先森 ⋅ 昨天 ⋅ 0


其实算不上一个游戏,就是两张图片,不停的重画,改变ball图片的位置。一个左右直线碰撞的,一个有角度碰撞的。 左右直线碰撞 package com.bjsxt.test;import javax.swing.*;import j...

森林之下 ⋅ 昨天 ⋅ 0

你真的明白RPC 吗?一起来探究 RPC 的实质

你真的明白RPC 吗?一起来探究 RPC 的实质 不论你是科班出身还是半路转行,这么优秀的你一定上过小学语文,那么对扩句和缩句你一定不陌生。缩句就是去除各种修饰提炼出一句话的核心,而不失基...

AI9o後 ⋅ 昨天 ⋅ 0


今天碰到了一个问题,就是在给li设置提示框的时候,有用到遮罩效果,本来想把对应的出现在最顶层,可是不管将li设置的z-index值设为多大,li都没有出现在遮罩层之上。 我在网上查了z-index设...

IrisHunag ⋅ 昨天 ⋅ 0



申文波 ⋅ 昨天 ⋅ 0



Cobbage ⋅ 昨天 ⋅ 0


1.Sqoop: 《=》 SQL to Hadoop 背景 1)场景:数据在RDBMS中,我们如何使用Hive或者Hadoop来进行数据分析呢? 1) RDBMS ==> Hadoop(广义) 2) Hadoop ==> RDBMS 2)原来可以通过MapReduce I...

GordonNemo ⋅ 昨天 ⋅ 0


1.全量构建每次更新时都需要更新整个数据集,增量构建只对需要更新的时间范围进行更新,所以计算量会较小。 2.全量构建查询时不需要合并不同Segment,增量构建查询时需要合并不同Segment的结...

无精疯 ⋅ 昨天 ⋅ 0