Re: [SLUG] better way to consolidate shell commands

From: Mike Branda (mike@wackyworld.tv)
Date: Thu Aug 19 2004 - 18:15:33 EDT


> for number in `seq 1 123` ; do
> machine=192.168.3.$num
> command='df -h'
> echo attempting to ssh to $machine as root
> ssh root@$machine "$command"
> done
>
> ? Anyhow, allowing root to ssh in is a bit of a security risk. You don't
> know who is doing it; whereas, if you don't allow it and require everyone
> to log in and su, you get a log entry something like "session opened for
> user root by eben(uid=500)".
>
> > and so on all the way through .123 at the end. If I want to see
> > something else I just do a search and replace of whatever is in quotes.
> > While this gets the job done, I know that this way is not very efficient
> > and it will get worse as more nodes are added. In an effort to learn
> > more, can anybody tell me if there's a way to add a variable that
> > increases by a factor of 1 until it reaches a certain number (say
> > .123)??
>
> It seems I already took care of this. Whoops. So much for listening
> before I talk. :-)
>
> > If this could be done, I could just change the stop point for
> > the variable. In addition to this does anybody know where any good web
> > tutorials are for sh and bash scripting basics??
>
> Hang out in comp.unix.shell. Read what Chris F. A. Johnson writes; he's
> good.

Eben, what you gave me worked great with the exception that I had to
change "number" in the for statement to "num". I don't know enough
about sh scripting yet to know if this was proper or not. It kept
giving this as the output:

attempting to ssh to 192.168.3. as root
ssh: 192.168.3.: Name or service not known

so due to the missing last number I assumed it was having trouble
calling that variable. after the change it worked great!! The plus to
your version is that I can enter a starting machine number too so the
group of machines can vary. I do realize the security risk of root in
this scenario. Usually I do the ssh as a user since my user shares an
rsa key also. However, sometimes I have to remove privileged temp files,
do an occasional reboot of the systems, or other things that need root
priv's. Not to mention the fact that most of the people here don't know
how to check their M$ based e-mail let alone even log on to my linux box
which is the only place with the shared keys. I change them fairly
often too so this hopefully minimizes the risk. thanks again for your
help! I'll check that google group out too.

Mike Branda

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:01:51 EDT