Personally, I highly recommend you to not use such scripts where you either specify passwords on the command line, or by storing them in a text file. If your system will be compromised, you will definitely regret about that. Take in mind, that the first thing bad people looking into is your .bash_history.

Don't put your password into a shell script. Shell scripts are not the place to put your password. Putting your password into a shell script is inadvisable. It is not recommended to put your password into a shell script.

If the above advice is not clear, repeat it a few dozen more times until it is.

With SSH your best bet is to use ssh-keygen to make a public/private key pair. Then, on the remote machine, in ~/.ssh (or wherever your SSH has been set up to look for its configuration) edit the file authorized_keys and paste your PUBLIC key. The file will, afterwards, look something like this: