HTTPプロキシを経由して ssh するにはconnectコマンドをProxyCommand指定すればいいと言うことが分りました
設定例
~/.ssh/config 23 Host mm 24 Hostname ssh.example.com 25 ProxyCommand connect squid.example.com:3128 %h %p
しかし、22番へのCONNECTを拒否するのがSquid
squid のデフォルト設定は22番へのCONNECTを許可しません
squid.conf
# Deny requests to unknown ports http_access deny !Safe_ports # Deny CONNECT to other than SSL ports http_access deny CONNECT !SSL_ports
と、SSL_Port以外のCONNECTはDenyします。Safe_Ports以外のアクセスはDenyします
Safe_Pors,SSL_Ports がどうなっているか
デフォルトでは次のようになっています.
acl SSL_ports port 443 # https acl SSL_ports port 563 # snews acl SSL_ports port 873 # rsync acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl Safe_ports port 631 # cups acl Safe_ports port 873 # rsync acl Safe_ports port 901 # SWAT acl purge method PURGE acl CONNECT method CONNECT
つまりConnectが出来る先のポートは 443/563/873 でした
また、プロキシ接続可能ポートに22番がありません.
ではどうするか?
squid.conf に以下のように記述すればいいと分ります
acl SSL_ports port 22 acl Safe_ports port 22
HTTPプロキシの管理者ならできますね
プロキシ設定が出来ない場合
22番を使わなければいいのです.
接続先のsshdの待ち受けポートを22 から443に追加(変更)します。
/etc/ssh/sshd_config
# Package generated configuration file # See the sshd(8) manpage for details # What ports, IPs and protocols we listen for Port 22 Port 443 #←ここを追加します. # Use these options to restrict which interfaces/protocols sshd will bind to #ListenAddress :: #ListenAddress 0.0.0.0 Protocol 2
発見、sshd の待ち受けポートは二つ書けた!!! - ブックマクロ開発ににあるように、待ち受けポートは簡単に追加できます.iptablesを持ち出すまでもないのです。