Passing variables to remote hosts through ssh



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?

Thanks.
.



Relevant Pages

  • Re: SSH: remote login returns "invalid user"
    ... do you differentiate between client hosts and server hosts and most ... with your current account being "brownh" and you ... At present, I have three or four hosts on a LAN, and I can ssh from ...
    (Debian-User)
  • Re: openssh concerns
    ... in to ssh. ... No protection is afforded against DNS poisoning, ... Hosts with no reverse DNS ... big service providers like google and hotmail. ...
    (FreeBSD-Security)
  • Re: IPV6 & pf
    ... das einzige was mir auffällt sind icmpv6 Fehler. ... Oben sieht man die funktionierende Verbindung, ... Wenn Du auf beiden Hosts tcpdump vergleichst, ... ssh auch direkt pingen. ...
    (de.comp.os.unix.bsd)
  • 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)