SSH – Tunnel an SSH Connection Through an Intermediate Machine in a Single Command

sshtunneling

Is there a way, in a single command, to establish a ssh connection from my computer A, through computer B, to computer C, such that I have access to the shell on computer C?

A wrinkle (which seems to rule out simply forwarding the ssh connection using the -L option) is that I have the password to the account on computer B, and the account on computer B is authorized to connect to the account on computer C, but I do not have the password to the account on computer C.

Best Answer

I understood that you want just to log in to the computer C, not really tunnel anything from A to C. So, this should do the trick:

ssh -t computer-b "ssh computer-c"

You might have to enter passwords twice, first for computer B and then for computer C, but this can be avoided by using ssh's key-pair authentication.

Related Topic