>
> >> Trying to run this but it isn't working - I'm suspecting it's the
> quotes:
> >>
> >> $ ssh machine1 "ssh machine2 "mysql -e "show databases"""
>

You've got an interesting approach, but why not enable MySQL's tcp stack on
a routable address and and allow a query from a specific user at machine1?
 That way, your command only needs to go through one host.

$ ssh myuser at machine1 mysql -h machine2 -e "show databases"

Take a look at your GRANT permission statements in the MySQL manual and
figure out what you need to do to allow this command.  Check your
bind_address in /etc/mysql/my.cnf to make sure it's a routable address
(rather than 127.0.0.1).  Also consider setting iptables firewall rules on
machine2 to protect port 3306 (DROP by default, ALLOW a specific list of
IP's).

You can store your MySQL "myuser" password in ~/.my.cnf so that you don't
need to specify it on the command-line (in case machine1 is
multi-user/public shell box).

Once you've done this, however, you could play with SSH tunneling to do port
forwarding from machine1 to machine2, and on your own workstation, you can
run the commands.  Using SSH to forward SSH connections is a bit convoluted.

If you're running into password problems, make your ssh keys and allow
authentication forwarding.  So many ways to skin this cat!

Good luck!

Chad

-- 
Chad Walstrom <gchewie at gmail.com>
http://google.com/profiles/gchewie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20110618/acba7598/attachment.html>