First of, like the other respondents, I recommend just using ssh keys. But I will assume that the person controlling the server is simply not going to allow you to use ssh key authentication and you must use password authentication.
You can use ControlMaster and ControlPath.
Let A be the server that you wontwon't have access to (think continuous integration server like Bamboo) and C be the remote host running Ubuntu.
Now let B be some computer that you control. If you can not provide a suitable B computer, this answer will not work.
- Create a key pair and add the public part to B's authorized_keys file. Give A the private key. Now you can log into B from A without a password.
- On B manually
ssh -M -S /tmp/controlpath Cand enter your password at the prompt. After that you should be able to log into C from A without a passwordssh -S /tmp/controlpath C.
In the script on A you can write ssh B ssh C dostuff.
Every time you reboot B, you will have to reestablish the connection ssh -M -S /tmp/controlpath C.