Q:

Running ssh sudo asynchronously

I'm trying to run a command with sudo on a remote machine. When I do it directly with 
ssh -t -t -t myserver -q "sudo otheruser<<EOF
remotescript.sh
EOF"

it works fine, but if I add & at the end of the last line then it doesn't work. Why? How can I make it work?
I fact I'm running several such commands (to different servers) from a local script and save each output in a different file and would like them to run asynchronously.
Note: running ssh with otheruser@myserver is not an option. I really need to run sudo after I logged in.

A:

Remove requiretty from sudo config (/etc/sudoers) on the remote machine.
Also add the -f option to ssh which puts the command in background (man: "must be used when ssh is run in the background").
The "&" should not be needed when using -f.
E.g:
ssh -f -t -t -t myserver -q "sudo otheruser<<EOF
remotescript.sh
EOF"

