Re: Passing variables to remote hosts through ssh



Earthdog <nobody@xxxxxxxxxx> writes:

Hi,

I have a central administration server that has root-level public key
access to my other hosts. I run scripts that use ssh to execute commands
on all my hosts. How do I pass variables through ssh?

For example, suppose I want to create a directory called /tmp/newdir on
100 hosts:

#/bin/ksh

DIRNAME=newdir

for i in `cat /long/list/of/hosts`

do
ssh $i '/usr/bin/mkdir /tmp/$DIRNAME'
done

This doesn't work, because $DIRNAME doesn't get passed to the remote host.
How can I make it work without hardcoding newdir in the ssh line?

change the ' to "
' says do not expand the stuff inside. " says do expand the stuff inside So
if you do
ssh $i "/usr/bin/mkdir /tmp/$DIRNAME"
the $DIRNAME will be expanded to newdir on the local machine.



Thanks.
.



Relevant Pages

  • Re: Whats the deal on the -X vs -Y thing?
    ... As a quick fix you could use something like this as your remote ssh ... chain is compromised (eg at either the tty layer, X11 forwarding port ... forwarding would not be needed on the intermediate hosts. ...
    (comp.security.ssh)
  • Re: what checking should FW-1 perform?
    ... >> some selected hosts on the other side. ... >> So I am going to supply the source IP, username and SSH public dsa key ... >> for each client with a list of IPs want to connect to. ...
    (comp.security.ssh)
  • Re: Apache Software Foundation Server compromised, resecured. (fwd)
    ... >> to selectively forward keys to hosts, or express policy regarding whether ... >> keys are then forwarded by the host you have connected to. ... My biggest complaint with ssh is the way ...
    (FreeBSD-Security)
  • inconsistent problems with "set tunnel=ssh ..." in mutt
    ... It works from some hosts and not from others (mostly all debian unstable ... machines), it also works from localhost. ... Google searches on "ssh bad packet" etc. didn't return anything beyond ...
    (comp.security.ssh)
  • Re: can openssh/logins be exploited this way?
    ... maybe i didnt quite explain the dyndns problem. ... saved into my known hosts, ... > As far as SSH is concerned, the point here is that you shouldn't have done ... When you connected for the first time to ...
    (comp.security.ssh)