./ssh/config ファイルを使用してリバース SSH トンネルを確立するにはどうすればよいですか?
このコマンドを再現しようとしています
ssh -R 55555:localhost:22 user@host
.ssh/config ファイルに、入力すると、ssh host
ユーザーとしてホストにリバース トンネルで ssh するようにします。構成ファイルで受け入れられるコマンドは、コマンド ライン フラグのより詳細な対応物です。ssh のマニュアル ページと ssh_config のマニュアル ページに基づくと、対応する設定は BindAddress のようです。
私の .ssh/config ファイルには次の内容が含まれています:
Host host
Hostname host
User user
BindAddress 55555:localhost:22
これと、そのわずかな違いにより、接続しようとすると拒否される。
ssh localhost -p 55555
ホストにログインしたら、同じことが起こります。ホストに最初に ssh するときに、先頭にコマンドを明示的に指定すると、同じようにうまくいきます。私の設定ファイルは、リバース トンネル コマンドなしでも機能し、ssh host
ユーザーとしてホストにログインします。
答え1
BindAddress
あなたが求めている選択肢ではありません。man ssh_config
:
BindAddress
Use the specified address on the local machine as the source
address of the connection. Only useful on systems with more than
one address.
に相当する設定ファイルは次のとおり-R
ですRemoteForward
:
RemoteForward
Specifies that a TCP port on the remote machine be forwarded over
the secure channel to the specified host and port from the local
machine. The first argument must be [bind_address:]port and the
second argument must be host:hostport. [...]
この情報を使用してコマンドライン
ssh -R 55555:localhost:22 user@host
次の.ssh/config
構文に変換されます。
Host host
HostName host
User user
RemoteForward 55555 localhost:22