usingUsing SSH there is a clear solution:
on your local machine set up your ~/.ssh/config
~/.ssh/configsuch that it has the following:host WhatYouWillCallTheConnection hostname the.gateway.server.address.com user YourUsernameOnTheGateway
host WhatYouWillCallTheConnection hostname the.gateway.server.address.com user YourUsernameOnTheGatewayOn both the gateway and the end server you'd like to connect to, make sure that you have your local client's public keys located in the ~/.ssh/authorized_keys
~/.ssh/authorized_keysOn the gateway machine you need to alter the ~/.ssh/authorized_keys
~/.ssh/authorized_keyssuch that at the beginning of the line that specifies your client's public key, add the forced command as follows:command="ssh -A [email protected]" ...yourPublicKey....
command="ssh -A [email protected]" ...yourPublicKey....
The -A-A is to forward the agent if you don't like to send passwords all the time...
This way, anytime you do something like ssh WhatYouWillCallTheConnection it will run straight through the gateway and connect you to the server on the other side transparently.