ほるっふー

自宅のベランダに鳩が住み着いた話を5万人の前ですること。

多段sshでWオプションが使えない時

多段sshでサーバーにログインしたい時

~/.ssh/configファイルに以下のように記入するとスムーズにログインできる。

 

Host gate

     HostName gate.hoge.ac.jp

 

Host server

     HostName server.hoge.ac.jp

     ProxyCommand ssh -W %h:%p gate

 

次のように連続してパスワードを聞かれてログインができる。

[local] smith $ ssh server

smith@gate.hoge.ac.jp's password: 

smith@server.hoge.ac.jp's password: 

Last login: Fri Jan 23 22:40:09 2015 from 123.456.789.012

[server] smith: ~ $ 

 

ところが一度gateに入ってからserverに入りたくなった時

[local] smith :~ $ ssh gate

smith@gate.hoge.ac.jp's password: 

Last login: Fri Jan 23 22:40:09 2015 from 123.456.789.012

[gate] smith :~ $ ssh server

ssh: illegal option -- W

usage: ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]

           [-D [bind_address:]port] [-e escape_char] [-F configfile]

           [-i identity_file] [-L [bind_address:]port:host:hostport]

           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]

           [-R [bind_address:]port:host:hostport] [-S ctl_path]

           [-w tunnel:tunnel] [user@]hostname [command]

-W オプションが無いと怒られた。

どうもOpenSSHのバージョンでWオプションが存在しない事がある。

今回たまたまgateのサーバーが-Wオプションに対応していなかった場合を想定している。

 

-W の代わりに次のコマンドが使えて

Host gate

     HostName gate.hoge.ac.jp

 

Host server

     HostName server.hoge.ac.jp

     ProxyCommand ssh nc gate %h %p

と書くと比較的どこからでもうまく入れる。