Need help: SSH+Proxy

Is there a way to automate this workflow?

I have a script to help me complete these tasks, but I wanted to find a way to do it without my input or frontend scripting:

  1. SSH to connect to a server for a company I work with;
  2. Enter the password using keychain;
  3. Change global proxy settings (this could be the first task);
  4. Then a script to revert it all.

Thank you all!