cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Etc


Reference














.

protocol:ssh:proxycommand.html



SSH

How to use ProxyCommand with ssh

Proxy Command Image

+--------+           +----------+            +----------+
| client | --------> | gateway  |----------->| server   |
|        |           |  1.2.3.4 |            |  5.6.7.8 |
+--------+           +----------+            +----------+

SSH ProxyCommand

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

SSH ProxyCommand with .ssh/config

use nc command
Host gateway
    HostName 1.2.3.4

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


use ssh -W
Host gateway
    HostName 1.2.3.4

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


use connect command
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
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 install connect command
$ wget http://www.meadowy.org/~gotoh/ssh/connect.c
$ gcc connect.c -o /usr/local/bin/connect/connect





SSH




protocol/ssh/proxycommand.html.txt ยท Last modified: 2017/06/01 by admin

Page Tools