SSH認証にはプロキシが必要です

SSH認証にはプロキシが必要です

私達の会社にかなり企業の代理店があります。会社のネットワーク外の一部のコンピュータにSSH経由で接続する必要があります。ただし、プロキシには認証が必要です。

次のような変数があるとしましょう。

proxy_user="<username I need to authenticate at the proxy>"
proxy_pass="<password I need to authenticate at the proxy>"
proxy_serv="<hostname of the proxy>"
proxy_port=<port of the proxy>
ssh_user="<remote username I need to login on the ssh-machine>"
ssh_serv="<remote password I need to login on the ssh-machine>"
ssh_port=<ssh-port>

環境変数http_proxyとhttps_proxyが次のように設定されていると、wgetなどのツールが正しく機能します(リモートサーバーにはweb_serverもインストールされています)。

$ export env http_proxy="http://$proxy_user:$proxy_pass@$proxy_serv:$proxy_port"

$ wget $ssh_serv
Connecting to <proxy_serv>... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

しかし、SSHでは動作しません。

$ ssh $ssh_user@$ssh_server:$ssh_port
ssh: Could not resolve hostname <ssh_server>:<ssh_port> Temporary failure in name resolution

インターネット検索の後、sshに「ProxyCommand」が必要であることがわかりました。ここでは「nc」の使用を推奨しません。 「ssh -W」を使用する必要があります。ところで、認証が必要な例が見つかりません。私は以前試しました:

ssh -o "ProxyCommand='ssh -W %h:%p $proxy_user:$proxy_pass@$proxy_serv:$proxy_port'" $ssh_user@$ssh_serv:$ssh_port

どこかで何か欠けているようですが(マニュアルやGoogleで)良いヒントが見つかりません。

あなたの一部が私を助けることを願っています。

ベストアンサー1

これで、数時間のインターネット検索の最後に「オフナー」の助けを借りて、ついに機能するようになりました。私のSSHサーバーは現在ポート443で実行されています(ポート22でも実行できることをまだ確認していません)。

~/.ssh/config

Host <my.ssh.server>
    ProxyCommand corkscrew <my.companies.proxy> <proxy.port> %h %p ~/corkscrew-auth

~/.corkscrew-auth

<proxies.username>:<proxies.password>

これで、私のサーバーに接続できます。

ssh <remote.user>@<my.ssh.server> -p 443

おすすめ記事