I am attempting to set up an alias to get from my local box into our main server and then subsequently into an internal box. I'm setting up RSA keys to make this fast, but it would be really nice if I can alias the whole operation to a single short command. Split into parts, it would be two steps:
local> ssh x.x.x.x
x.x.x.x> ssh y.y.y.y
y.y.y.y>
I would prefer to use an alias "sshtoy" that accomplish both of these in one go, but I don't know how to chain these together. And with the RSA keys in place, I would magically end up on internal server y without all the typing. Any ideas? Can this be done?
Okay. This one was pretty easy to find. Due diligence...
ssh -A -t server1 ssh -A -t server2 ssh -A server3
This will allow you to chain transparently from one server to the next, entering passwords as you go for each. With RSA keys set up and no passwords, you end up at server3 right away. To put this in an alias, you'd add the following to your ".bashrc" file.
alias sshto3="ssh -A -t server1 ssh -A -t server2 ssh -A server3"
Hope this helps someone.
-A Enables forwarding of connections from an authentication agent such as ssh-agent(1). This can also be specified on a per-host basis in a configuration file.
-t Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu
services. Multiple -t options force tty allocation, even if ssh has no local tty.