From: bzaman on
Hi ,

I need to execute some commands remotely on a large number of hosts
using ssh . passphraseless access is setup between the clients and all
the remote hosts . The command looks like this .

for i in {1..28} ; do ssh -i /home/zaman/.ssh/id_rsa rabbit-p
$i.example.com <some command> ; done

Since I have to execute the command from each of the host to all the
hosts , so I have to babysit for sometime . My worry is since from
these hosts I will be connecting to the remote host for the first
time , I have to press "YES" for each of the host like this .

=====
for i in {1..28} ; do ssh -i /home/zaman/.ssh/id_rsa rabbit-p
$i.example.com uptime ; done
The authenticity of host 'rabbit-p1.example.com (98.136.0.55)' can't
be established.
DSA key fingerprint is 1f:e0:2d:c2:7c:b6:1d:71:bb:b4:3f:
61:a4:0f:f0:d0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rabbit-p1.example.com' (DSA) to the list
of known hosts.
2:12AM up 102 days, 8:47, 1 user, load averages: 0.26, 0.21, 0.11
=====

Is there is anyway to automatize the pressing of "YES" everytime by
using any tool or I have to write a script for that. Please give ur
views . Also , some pointers on how to write the script will be highly
appreciated.

Thanks in Advance
-Bz



From: Florian Diesch on
bzaman <bzaman.laskar(a)gmail.com> writes:

> I need to execute some commands remotely on a large number of hosts
> using ssh . passphraseless access is setup between the clients and all
> the remote hosts . The command looks like this .
>
> for i in {1..28} ; do ssh -i /home/zaman/.ssh/id_rsa rabbit-p
> $i.example.com <some command> ; done
>
> Since I have to execute the command from each of the host to all the
> hosts , so I have to babysit for sometime . My worry is since from
> these hosts I will be connecting to the remote host for the first
> time , I have to press "YES" for each of the host like this .

You can set
StrictHostKeyChecking=no
if you don't care about nonexisting or changed host keys.



Florian
--
<http://www.florian-diesch.de/doc/emacs/>
From: Wanna-Be Sys Admin on
bzaman wrote:

> Hi ,
>
> I need to execute some commands remotely on a large number of hosts
> using ssh . passphraseless access is setup between the clients and all
> the remote hosts . The command looks like this .
>
> for i in {1..28} ; do ssh -i /home/zaman/.ssh/id_rsa rabbit-p
> $i.example.com <some command> ; done
>
> Since I have to execute the command from each of the host to all the
> hosts , so I have to babysit for sometime . My worry is since from
> these hosts I will be connecting to the remote host for the first
> time , I have to press "YES" for each of the host like this .
>
> =====
> for i in {1..28} ; do ssh -i /home/zaman/.ssh/id_rsa rabbit-p
> $i.example.com uptime ; done
> The authenticity of host 'rabbit-p1.example.com (98.136.0.55)' can't
> be established.
> DSA key fingerprint is 1f:e0:2d:c2:7c:b6:1d:71:bb:b4:3f:
> 61:a4:0f:f0:d0.
> Are you sure you want to continue connecting (yes/no)? yes
> Warning: Permanently added 'rabbit-p1.example.com' (DSA) to the list
> of known hosts.
> 2:12AM up 102 days, 8:47, 1 user, load averages: 0.26, 0.21, 0.11
> =====
>
> Is there is anyway to automatize the pressing of "YES" everytime by
> using any tool or I have to write a script for that. Please give ur
> views . Also , some pointers on how to write the script will be highly
> appreciated.
>
> Thanks in Advance
> -Bz

Either set SSH to not care and check (because with so many target hosts,
will you really know if it looks legit without checking anyway?)
Unless you can't trust the person that runs the resolve servers you
use, or your system or local network, or something such as that, or
can't trust the DNS, then you can probably safely ignore the warnings
anyway. If you're going to automate it to respond with yes (look into
expect if you want to do that), you may as well do it the easier way
and not have it check for authenticity w/ StrictHostKeyChecking=no
--
Not really a wanna-be, but I don't know everything.
From: Nico Kadel-Garcia on
On Jan 18, 9:09 am, Florian Diesch <die...(a)spamfence.net> wrote:
> bzaman <bzaman.las...(a)gmail.com> writes:
> >   I need to execute some commands remotely on a large number of  hosts
> > using ssh . passphraseless access is setup between the clients and all
> > the remote hosts . The command looks like this .
>
> >  for i in {1..28} ; do ssh -i /home/zaman/.ssh/id_rsa rabbit-p
> > $i.example.com  <some command>  ; done
>
> > Since I have to execute the command from each of the host to all the
> > hosts , so I have to  babysit for sometime . My worry is since from
> > these hosts I will be connecting to the remote host for the first
> > time , I have to press "YES" for each of the host like this .
>
> You can set
>   StrictHostKeyChecking=no
> if you don't care about nonexisting or changed host keys.

Or use it in the command line, or run a pre-scan to record the
hostkeys.

ssh -o 'StrictHostKeyChecking no' targethost

There are also a stack of small tools for bundling up this sort of
parallel SSH operation, such as "dssh"., which you may find useful.