I want to be able to copy a mysqdump from a remote server to my local machine.
I had a script to do this, but our operations guys have now changed the server permissions and it doesn't work.
So before I could SSH from my machine login as root and supply a password and connect to mysql, so I had a command in a Perl script like so :
sshpass -p root_password ssh root@$servername mysqldump $database_name > $mysqldump_location
Anyway, permissions have changed and I can't login using root from my local machine.
Now I need to
- login to the remote server with a deploy user.
- Once I am logged in, I need to use su - to get the root user
- Now I can execute the mysqldump command (the deploy user gets an access denied message)
I want to have a script or command that I can execute from my local machine and have it go through the steps - log in as deploy, switch to root, create a mysql dump and copy it to my local machine.
What is the best way to go about that? Is it possible with SSH tunnels? Or is a scripted option better (how do you script multiple logins)?