Table of Contents

SSH - transparent Multi-hop SSH (How to use ProxyCommand with ssh)



Proxy Command Image


+--------+           +----------+            +----------+
| local  | --------> | bastion  |----------->| server   |
|        |           |  1.2.3.4 |            |  5.6.7.8 |
+--------+           +----------+            +----------+


How to use ssh -W

How to multi-hop ssh in one line

ssh -oProxyCommand='ssh -W %h:%p 1.2.3.4'  5.6.7.8
ssh -oProxyCommand='ssh -W %h:%p user01@1.2.3.4'  user01@5.6.7.8


How to describe settings in .ssh/config

Host bastion
    HostName 1.2.3.4

Host server
    HostName 5.6.7.8
    Port 22
    ProxyCommand ssh -W %h:%p bastion


How to use ssh command
ssh server

scp file server:/tmp

rsync dir1/ server:/tmp/dir1/


How to use nc command

How to describe settings in .ssh/config
Host bastion
    HostName 1.2.3.4

Host server
    HostName 5.6.7.8
    Port 22
    ProxyCommand ssh bastion nc %h %p


How to use connect command

How to multi-hop ssh in one line

scp -o 'Proxycommand=/usr/local/bin/connect/connect -h 192.168.0.10 -p 9999' tmp.txt testuser@xx.xx.xx.xx:/tmp/


How to describe settings in .ssh/config
Host test-server1
  HostName xx.xx.xx.xx
  IdentityFile ~/.ssh/id_rsa-test.pub
  User testuser01
  ProxyCommand connect -H xx.xx.xx.xx:9999 %h %p


How to install connect command

$ wget http://www.meadowy.org/~gotoh/ssh/connect.c
$ gcc connect.c -o /usr/local/bin/connect/connect





SSH