
サーバー に接続するために 2 回のプロキシ ジャンプを実行する必要がある設定がありますD
。 実際にはA
、 から に接続する必要がありB
、そこから に接続する必要がありC
( からの接続のみを許可B
)、そこから に接続できますD
( からの接続のみを許可C
)。
ではB
、ssh 設定を使用して、D
と入力するだけでに接続できますssh D
。そのため、 でこの設定を使用してA
に接続できると考えましたD
。
Host B
hostname 127.0.0.1
user myUser
Port 43099
IdentityFile ~/.ssh/id_rsa
Host D
hostname D
ProxyJump B
そして から に接続し、経由A
で に接続します。D
ssh D
ただし、次のようなエラーが発生します:
debug1: Reading configuration data /home/MyUser/.ssh/config
debug1: /home/MyUser/.ssh/config line 17: Applying options for D
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Setting implicit ProxyCommand from ProxyJump: ssh -v -W '[%h]:%p' B
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Executing proxy command: exec ssh -v -W '[D]:22' B
debug1: Local version string SSH-2.0-OpenSSH_8.8
OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021
debug1: Reading configuration data /home/MyUser/.ssh/config
debug1: /home/MyUser/.ssh/config line 7: Applying options for B
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 43023.
debug1: Connection established.
debug1: identity file /home/MyUser/.ssh/id_rsa type 0
debug1: identity file /home/MyUser/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.6
debug1: compat_banner: match: OpenSSH_8.6 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 127.0.0.1:43023 as 'MyUser'
debug1: load_hostkeys: fopen /home/MyUser/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:to5+n56a6Zj+sbTnMghZGehX2OX5cn29HWbje55WJHU
debug1: load_hostkeys: fopen /home/MyUser/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '[127.0.0.1]:43023' is known and matches the ED25519 host key.
debug1: Found key in /home/MyUser/.ssh/known_hosts:45
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/MyUser/.ssh/id_rsa RSA SHA256:d6hsPtnc6TWfm9j5lOClBzD4ylE+ww/tg9BE7qP8DlE explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /home/MyUser/.ssh/id_rsa RSA SHA256:d6hsPtnc6TWfm9j5lOClBzD4ylE+ww/tg9BE7qP8DlE explicit
debug1: Server accepts key: /home/MyUser/.ssh/id_rsa RSA SHA256:d6hsPtnc6TWfm9j5lOClBzD4ylE+ww/tg9BE7qP8DlE explicit
Authenticated to 127.0.0.1 ([127.0.0.1]:43023) using "publickey".
debug1: channel_connect_stdio_fwd: D:22
debug1: channel 0: new [stdio-forward]
debug1: getpeername failed: Bad file descriptor
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: filesystem full
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: client_input_hostkeys: searching /home/MyUser/.ssh/known_hosts for [127.0.0.1]:43023 / (none)
debug1: client_input_hostkeys: searching /home/MyUser/.ssh/known_hosts2 for [127.0.0.1]:43023 / (none)
debug1: client_input_hostkeys: hostkeys file /home/MyUser/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: host key found matching a different name/address, skipping UserKnownHostsFile update
debug1: Remote: /Users/Hendrik/.ssh/authorized_keys:3: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /Users/Hendrik/.ssh/authorized_keys:3: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
channel 0: open failed: connect failed: nodename nor servname provided, or not known
stdio forwarding failed
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
ssh 設定がB
まったく読み込まれていないようです。
私の ssh 設定はB
次のようになります:
Host C
HostName C
User MyUser
ForwardX11Trusted yes
ForwardX11 yes
Host D
User MyUser
HostName D
ProxyCommand ssh %r@C -W %h:22
RemoteForward 26512 github.com:22
Compression yes
ForwardX11Trusted yes
ForwardX11 yes
DynamicForward 10080
ControlMaster auto
ControlPath ~/.ssh/masters/%C
からにA
接続できるように のSSH 設定を編集する方法はありますか?A
D
ssh D
答え1
プロキシ ジャンプを使用する場合、すべての SSH 接続は元のクライアント (この場合は A) から開始され、中間ノードはトンネルのエンドポイントになります。したがって、この場合は、すべての構成 (秘密キー ファイルを含む) が A 上にある必要があり、次のようになります (3 つのホストすべてに同じ ID ファイルを使用すると仮定)。
Host B
hostname 127.0.0.1
user myUser
Port 43099
IdentityFile ~/.ssh/id_rsa
Host C
ProxyJump B
IdentityFile ~/.ssh/id_rsa
# Any additional options for connecting to C
Host D
ProxyJump C
IdentityFile ~/.ssh/id_rsa
# Any additional options for connecting to D
するとssh D
、A 上の ssh クライアントは次の一連の ssh セッションを作成します。
- A -> B (ネットワーク経由で直接)
- A -> C (A->B 接続をトンネルし、その後ネットワーク経由で直接 B から C へ)
- A -> D (A->C 接続 (A->B 経由でトンネリング) 経由でトンネリングされ、その後ネットワーク経由で直接 C から D へ)