<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">>> Trying to run this but it isn't working - I'm suspecting it's the quotes:<br>

>><br>
>> $ ssh machine1 "ssh machine2 "mysql -e "show databases"""<br></blockquote><div><br></div><div>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.</div>
<div><br></div><div>$ ssh myuser@machine1 mysql -h machine2 -e "show databases"</div><div><br></div><div>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).</div>
<div><br></div><div>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).</div><div><br></div><div>
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.</div>
<div><br></div><div>If you're running into password problems, make your ssh keys and allow authentication forwarding.  So many ways to skin this cat!</div><div><br></div><div>Good luck!</div><div><br></div><div>Chad</div>
<div><br></div></div>-- <br>Chad Walstrom <<a href="mailto:gchewie@gmail.com">gchewie@gmail.com</a>><br><a href="http://google.com/profiles/gchewie">http://google.com/profiles/gchewie</a><br>