1. 11

  2. 4

    This and other tricks are useful to know, for the weird times you need them.

    Anybody want to share their favorite similar SSH tricks?

    1. 4

      Here is a neat trick: You can add proxies to an existing connection via ~C:

      $ ssh myserver
      Supported escape sequences:
       ~.   - terminate connection (and any multiplexed sessions)
       ~B   - send a BREAK to the remote system
       ~C   - open a command line
       ~R   - request rekey
       ~V/v - decrease/increase verbosity (LogLevel)
       ~^Z  - suspend ssh
       ~#   - list forwarded connections
       ~&   - background ssh (when waiting for connections to terminate)
       ~?   - this message
       ~~   - send the escape character by typing it twice
      (Note that escapes are only recognized immediately after newline.)
      ssh> -L 8080:example.com:80
      Forwarding port.
      ssh> help
            -L[bind_address:]port:host:hostport    Request local forward
            -R[bind_address:]port:host:hostport    Request remote forward
            -D[bind_address:]port                  Request dynamic forward
            -KL[bind_address:]port                 Cancel local forward
            -KR[bind_address:]port                 Cancel remote forward
            -KD[bind_address:]port                 Cancel dynamic forward

      and (as noted in that output) if you’re in a “stuck” SSH connection, ~. kills it immediately.

      1. 4

        On OpenSSH 7.3/7.3p1 there is this wonderful new feature:

        • ssh(1): Add a ProxyJump option and corresponding -J command-line flag to allow simplified indirection through a one or more SSH bastions or “jump hosts”.

        So if you are using keys you can do things like:

        ssh -J bastion.hosakacorp.net management.hosakacorp.net

        So with some key usage you can easily get to other systems without having to deal with nasty -o ProxyCommand hacks. There is also ProxyJump for your configs.