SSH to a computer that will then SSH to another computer [duplicate]

Use the ProxyCommand ssh config variable.

Host inaccessible
ProxyCommand ssh accessible nc -w1 %h %p

This post even explains a way to use a generic config so ssh host1/host2 automatically jumps hosts for you.

Update: Fixed the hostnames in the config snippet as per toppledwagon's comment.


Use ssh tunnels, of course.


You can also do: ssh -t remotelyaccsbl ssh notremotelyaccsbl


I think this answer might be what you are looking for:

How to configure a shortcut for an SSH connection through a SSH tunnel


  1. Open tunnel:

    ssh -qTfnN -D 4040 -C login@remotely-accessible-host

  2. Set up SOCKS5 on localhost with 4040 port in cyberduck

  3. Connect to computer you want access to

    • q - quiet
    • T - without tty
    • f - move to background
    • N - not execute remote commands
    • n - redirect input to /dev/null.