You may find yourself in a situation where you need to connect to your server only through the gateway server.
There are several ways to accomplish this using Xshell.
Below is a sample of an OpenSSH configuration with the ProxyCommand setting:
+--------+ +----------+ +-----------+ | Source | <---> | gw_svr | <--> | dest_svr | +--------+ +----------+ +-----------+ |
$ ssh -o ProxyCommand='ssh user_of_gw_svr@gw_svr nc dest_svr 22' user_of_dest_svr@dest_svr |
$ vi ~/.ssh/config |
Host myserver # session name that can be any. HostName dest_svr # the real host name that can be reached. User user_of_dest_svr Port 22 ProxyCommand ssh user_of_gw_svr@gw_svr nc %h %p |
$ ssh myserver |
The expect string will differ, of course, depending on your situation.
Add the following to your sshd_config file and restart sshd:
AcceptEnv XSHELL_HOSTNAME XSHELL_USERNAME XSHELL_PASSWORD XSHELL_PORT XSHELL_PROTOCOL
Make a proxy configuration and select it in your session file.
$ vi ~/.bash_profile |
$ vi ~/.bash_profile if [ $XSHELL_PROTOCOL ]; then echo echo "Jumping to $XSHELL_HOSTNAME..." echo /usr/bin/expect -c " log_user 0 if { \"$XSHELL_PROTOCOL\" == \"TELNET\" } { spawn -noecho telnet $XSHELL_HOSTNAME $XSHELL_PORT -l $XSHELL_USERNAME expect -nocase \"assword:\" if { \"$XSHELL_PASSWORD\" != \"\" } { send \"$XSHELL_PASSWORD\r\" } } else { spawn /usr/bin/ssh $XSHELL_HOSTNAME -p $XSHELL_PORT -l $XSHELL_USERNAME expect { -nocase \"assword:\" { if { \"$XSHELL_PASSWORD\" != \"\" } { send \"$XSHELL_PASSWORD\r\" } } } } interact " logout fi |