マルチホップおよびプロンプト認証のためのProxyCommand

マルチホップおよびプロンプト認証のためのProxyCommand

次のコマンドをどのように書き換えることができますかProxyCommand

ssh -l username1 -t jumphost1 \
ssh -l username2 -t jumphost2 \
ssh -l username3 -t jumphost3 \
ssh -l username4    server

これはうまくいきません

ssh -o ProxyCommand="\
ssh -l username1 -t jumphost1  \
ssh -l username2 -t jumphost2  \
ssh -l username3 -t jumphost3" \
    -l username4    server

username1@jumphost1's password:
Pseudo-terminal will not be allocated because stdin is not a terminal.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
ssh_exchange_identification: Connection closed by remote host

で動作することを知っていますが、nc3つ以上のホップで使用し、このオプションも一緒に使用できる方法を探していますscp。マニュアルページを確認しましたが、ssh_config少なくとも私にとっては情報が非常にまれでした。

編集する

以下の提案に従って、ProxyCommand他の項目に入れ子になった機能を試しましたが、ProxyCommand常に次のような結果が表示されます。

debug3: ssh_init_stdio_forwarding: 192.17.2.2:2222
debug1: channel_connect_stdio_fwd 192.17.2.2:2222
debug1: channel 0: new [stdio-forward]
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: getpeername failed: Bad file descriptor
debug3: send packet: type 90
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.

幸いなことに、7.3 -JORはProxyJump私の目的を満たしていましたが、依然として主要な設定問題を解決する必要がありました。

ssh -q -J user1@jumphost1,user2@jumphost2,user3@jumphost3 user@server

ベストアンサー1

単純なssh構成ファイルの使用

nc最新バージョンではこのバージョンを使用しないことをお勧めします。代わりに、最新バージョンのOpenSSHでスイッチをssh使用してください。-Wまた、構成を別のホストにコピーする必要はありません!すべての構成はホスト上で行う必要があり、scpいかなる方法でも邪魔になりません。

~/.ssh/config以下は、その例のサンプルファイルです。

Host jumphost1
    User username1
Host jumphost2
    User username2
    ProxyCommand ssh -W %h:%p jumphost1
Host jumphost3
    User username3
    ProxyCommand ssh -W %h:%p jumphost2
Host server
    User username4
    ProxyCommand ssh -W %h:%p jumphost3

最後に、またはまたはssh serverscp file server:path/使って接続しますrsync


メモ

SSH設定ファイルでテキストの代わりに画像を使用したいユーザーのための信号フロー図は次のとおりです。

localhost
        ||
        \/
username1@jumphost1
        ||
        \/
username2@jumphost2
        ||
        \/
username3@jumphost3
        ||
        \/
username4@server


pps for fun 以下は 1 行の内容ですが、このアプローチは入力しにくく読みにくいことに注意してください。

ssh -oProxyCommand= \
  'ssh -W %h:%p -oProxyCommand= \
    \'ssh -W %h:%p -oProxyCommand= \
      \\\'ssh -W %h:%p username1@jumphost1\\\' \
    username2@jumphost2\' \
  username3@jumphost3' \
username4@server

基本的に内部から始める必要があります。

おすすめ記事