I'm trying to copy a database from one server to another. I tried using the following command and it's getting tied up on entering the ssh passwords. If I put in one server's password, it complains about the other and vice versa.
ssh root@server1 mysqldump --databases db | ssh root@server2 mysql
I managed to do the transfer by holding the dumps temporarily on my computer, just wondering if there is a way to get this to work.
Use ssh-keygen, copy the .ssh/ file that's generated to the other server, append the contents to the ./.ssh/authorized_keys file, then you can ssh into the other server without any password.
Using key authentication is definitely a valid way to go about it and what I'd probably do. If for some reason you can't do that, you can put a named pipe on the intermediate machine instead of storing the file there.
If, for some reason, you can't use key authentication and require entering two passwords to complete this, you could use a FIFO: