ssh で ProxyCommandが動かない問題の解決

ssh で多段ポートフォワーディングやプロキシを通す時に、~/.ssh/configにProxyCommandを設定してsshコマンドを実行しようとしたところ、下記のようなエラーが発生した。

$ ssh hoge
zsh: No such file or directory
write: Broken pipe

むむ、と思い、取り合えずデバッグモードで実行してみても..

$ ssh hoge -vvv
...
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Executing proxy command: exec ssh -CW 192.168.56.112:22 hoge
debug1: permanently_drop_suid: 197609
zsh: No such file or directory
...

エラーを見る限り、ProxyCommand内に設定しているコマンドを見つけることが出来ないのではなく、zsh自体のパスが解決できていない模様。

$SHELLを見てみると zshとなっている。

$ echo $SHELL
zsh

これをフルパスに直して実行すると、問題なく実行できた。

$ export SHELL=/bin/zsh
$ ssh hoge