LoginSignup
9
7

More than 5 years have passed since last update.

ncコマンドを使わないSSH ProxyCommandの設定方法

Posted at

OpenSSH 5.4以上では-Wオプションを使用することでncコマンドがインストールされていないサーバもProxyCommandで利用することができるようになっています。

これまでのncコマンドを使った書き方

Host node-*
  ProxyCommand ssh proxy_host nc -w 6000 %h %p

ncコマンドを-Wオプションに置換えた書き方

Host node-*
  ProxyCommand ssh -W %h:%p proxy_host

下記の例の様に記述すると、ssh nodes-node1など、nodes-*にマッチした際ににProxyCommandが使用される。

Host proxy_host
  HostName 10.0.0.1
  User ubuntu
  IdentityFile /Users/hoge/.ssh/proxy_key

Host nodes-*
  ProxyCommand ssh -W %h:%p proxy_host

Host nodes-node1
  HostName 192.168.0.1
  User ubuntu

Host nodes-node2
  HostName 192.168.0.2
  User ubuntu
9
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
7