
내 서버에 연결하기 위해 2개의 프록시 점프를 수행해야 하는 설정이 있습니다 D
. 효과적으로, 에서 A
에 연결해야 하고 B
, 에서 에 연결해야 하며 , 에서 까지 C
의 연결만 허용합니다 . 에서 까지의 연결만 허용합니다 .B
D
C
에서 ssh 구성을 사용하면 간단히 입력하여 B
연결할 수 있습니다 . 이것이 바로 이 구성을 사용하여 다음에 연결할 수 있다고 생각한 이유입니다 .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
A의 SSH 클라이언트 는 ssh D
다음과 같은 일련의 SSH 세션을 만듭니다.
- A -> B(네트워크를 통해 직접)
- A -> C(A->B 연결을 통해 터널링된 다음 B에서 C로 네트워크를 통해 직접)
- A -> D(A->C 연결(A->B를 통해 터널링됨)을 통해 터널링된 다음 C에서 D로 네트워크를 통해 직접)