I've tried the most popular solution to this, namely using the -t parameter on ssh and running a command before bash initializes. Sadly, the script I am trying to run requires bash variables so this is not an option for me. These are the approaches I've tried:
Approach 1:
Just to show what I was trying above:
ssh -A me@proxy -t 'echo 0 | /usr/local/bin/hop-server.sh <parameters> && bash -l'
It sshes into the proxy but then it spits out a number of missing environment variables from the script.
Approach 2:
Added the script into ~/.bashrc:
if [ "$HOP" = "dev1" ]; then
/usr/local/bin/hop-server.sh <parameters>
fi
And to connect:
ssh -A me@proxy -t 'HOP=dev1 bash -l'
This does not spit out environment variables as missing, but the hop does not succeed and I am stuck in the proxy:
me@proxy:~$ ~/proxytodev1
Setting environment variables...
Setting project...
Resolving 'dev1'...
Connecting to 123.123.123.123...
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-63-generic x86_64)
* Documentation: https://help.ubuntu.com/
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
17 packages can be updated.
9 updates are security updates.
me@proxy:~$
ssh -A me@proxy -t HOP=<dest> /usr/local/bin/hop-server.sh <params> && bash -lthough I'm not positive about thebash -lpart which is why I'm keeping this as a comment instead of an answer