-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcs.1
246 lines (246 loc) · 6.58 KB
/
cs.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
.\" Copyright (c) 2014 Andy Kosela. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.Dd July 19, 2017
.Dt CS 1
.Os
.Sh NAME
.Nm cs
.Nd concurrent ssh client
.Sh SYNOPSIS
.Nm cs
.Bk -words
.Op Fl emqrstuVv1
.Op Fl c Ar file
.Op Fl cmd
.Op Fl cname
.Op Fl d Ar file
.Op Fl dd
.Op Fl du Ar path
.Op Fl f Ar script.sh
.Op Fl h Ar hosts_file
.Op Fl hba
.Op Fl i Ar identity_file
.Op Fl io
.Op Fl ip
.Op Fl l Ar login_name
.Op Fl lip
.Op Fl mx
.Op Fl nc
.Op Fl nmap
.Op Fl ns
.Op Fl o Ar output_file
.Op Fl P Ar port
.Op Fl p Ar path
.Op Fl ping
.Op Fl soa
.Op Fl to Ar timeout
.Op Fl top
.Op Fl tr
.Op Fl tri
.Op Fl uname
.Op Fl vm
.Op Ar command
.Sm off
.Oo
.Op Ar user No @
.Ar host
.Oc
.Sm on
.Ar ...
.Sh DESCRIPTION
.Nm
is a program for concurrently executing local or remote commands on
multiple hosts.
It is using OpenSSH for running remote commands.
Its main purpose is to help automate and manage large network of hosts.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl c Ar file
Copy
.Ar file
to the remote machine.
.It Fl cmd
Run an arbitrary local command concurrently on multiple hosts.
.It Fl cname
Run a local DNS query of type CNAME.
.It Fl d Ar file
Download
.Ar file
from the remote machine.
It will be saved in a directory named after the remote host only when
you download from multiple servers.
.It Fl dd
Prints basic hardware information for a specific host (sudo(8) and
dmidecode(8) required).
.It Fl du Ar path
Prints the list of largest files in a specific directory (sudo(8)
required, units in M).
.It Fl e
Prints hosts with errors only.
.It Fl f Ar script.sh
Run a local shell script on the remote host.
.It Fl h Ar hosts_file
Read hostnames from the given
.Ar hosts_file .
Lines in the
.Ar hosts_file
can include commented lines beginning with a
.Sq Li #
and only one host per line is allowed.
.It Fl hba
Lists installed HBAs and their WWPNs (Linux only).
.It Fl i Ar identity_file
Selects a file from which the identity (private key) for public key
authentication is read.
The default is
.Ar ~/.ssh/id_rsa .
.It Fl io
Run remote iostat(1) on a specific host.
.It Fl ip
Lists network interfaces.
.It Fl l Ar login_name
Specifies the user to log in as on the remote machine.
This also may be specified on a per-host basis on the command line.
.It Fl lip
Scans storage interconnects for new luns (Linux only).
.It Fl m
Lists mounted filesystems on a speficic host.
.It Fl mx
Run a local DNS query of type MX.
.It Fl nc
Tests a specific port with nc(1).
Default is 22/tcp.
.It Fl nmap
Scans host with nmap(1).
.It Fl ns
Run a local DNS query of type NS.
.It Fl o Ar output_file
Saves standard output and standard error to a file.
.It Fl P Ar port
Port to connect to on the remote host.
.It Fl p Ar path
Specifies remote or local path for files in a remote copy or download
mode.
.It Fl ping
Sends ICMP ECHO_REQUEST to network hosts.
.It Fl q
Quiet mode.
Supresses verbose standard output from remote machines.
This mode reports success or failure only.
.It Fl r
Recursively copy entire directories.
It follows symbolic links encountered in the tree traversal.
.It Fl s
Sort output.
.It Fl soa
Run a local DNS query of type SOA.
.It Fl t
Force pseudo-tty allocation.
.It Fl to Ar timeout
Specifies the timeout (in seconds) used when connecting to the SSH
server.
The default value is 4 seconds.
.It Fl top
Run remote top(1) in batch mode on a specific host.
.It Fl tr
Run local traceroute(8).
.It Fl tri
Run local traceroute(8) using ICMP (local sudo(8) required).
.It Fl uname
Prints remote system information including OS version.
.It Fl u
Run remote uptime(1) on a specific host.
.It Fl V
Displays the version number and exit.
.It Fl v
Verbose mode.
Causes
.Nm
to print debugging messages from ssh(1) about its progress.
This is helpful in debugging connection, authentication, and
configuration problems.
Multiple
.Fl v
options increase the verbosity.
The maximum is 3.
.It Fl vm
Run remote vmstat(8) on a specific host.
.It Fl 1
One line mode, useful for sorting output later.
.El
.Sh AUTHENTICATION
The default method for authentication is a public key authentication
which serves its purpose when dealing with multiple hosts.
You can read more about public key authentication in
.Xr ssh 1 .
.Sh EXIT STATUS
.Ex -std cs
.Sh EXAMPLES
Run a series of commands on hosts foo and bar:
.Pp
.Dl $ cs 'uptime; uname -a' foo bar
.Pp
Run a command on multiple hosts specified in a hosts_file:
.Pp
.Dl $ cs -h hosts_file uptime
.Pp
Run a local shell script on multiple hosts:
.Pp
.Dl $ cs -f script.sh foo{1..100}
.Pp
Run a local shell script with sudo(8) on multiple hosts:
.Pp
.Dl $ cs -t -f script.sh foo{1..100}
.Pp
Copy file to multiple hosts using a specific remote path:
.Pp
.Dl $ cs -c file -h hosts_file -p /foo/bar
.Pp
Download file from host:~ foo to a current working directory:
.Pp
.Dl $ cs -d file foo
.Pp
Download recursively files from /foo/bar from multiple hosts to a
specific local path /tmp with subdirectories named after remote hosts:
.Pp
.Dl $ cs -r -d '/foo/bar/*' -h hosts_file -p /tmp
.Pp
Run a command on multiple hosts and sort the output:
.Pp
.Dl $ cs -1 -h hosts_file 'free -m | grep Swap' | sort -rnk4 | head
.Pp
Run local ping(1) on multiple hosts:
.Pp
.Dl $ cs -ping foo{1..100}
.Pp
Show name and size of all files matching the glob pattern:
.Pp
.Dl $ cs -du '/var/log/mes*' foo{1..100}
.Sh SEE ALSO
.Xr scp 1 ,
.Xr ssh 1 ,
.Xr ssh_config 5 ,
.Xr sudo 8
.Sh AUTHORS
.An Andy Kosela Aq [email protected]