멀티 홉 SSH는 작동하지만 "연결이 닫혔습니다"라는 메시지와 함께 scp가 닫힙니다.

멀티 홉 SSH는 작동하지만 "연결이 닫혔습니다"라는 메시지와 함께 scp가 닫힙니다.

중간 홉을 통해 로컬 컴퓨터에서 원격 컴퓨터로 파일을 전송하려고 합니다.

로컬 머신 -> hop_server -> 대상 서버

제안대로https://serverfault.com/a/489479/606674그리고https://unix.stackexchange.com/a/317644/142412, ~/.ssh/config를 다음과 같이 설정했습니다.

Host hop_server
HostName hop_server
User username
IdentityFile ~/.ssh/hop_key
                       
Host destination_server
User root
ProxyCommand ssh -W %h:%p hop_server          
IdentityFile ~/.ssh/destination_key

ssh를 사용하여 대상 서버에 성공적으로 연결할 수 있지만 다음을 사용하여 ssh destination_server로컬 파일을 복사하려고 하면scp test.txt root@destination_server:~/

scp: 연결이 닫혔습니다

scp에 로그가 없는 것 같습니다(https://askubuntu.com/a/660153/848577), 그래서,

첫째, 연결이 종료된 이유를 자세히 알아보려면 어떻게 해야 합니까?

둘째, 내가 뭘 잘못했나요?

편집하다:

ssh root@destination_server일하다. 따라서 루트 권한 문제는 아닙니다.

scp -v test.txt root@destination_server:~/다음 출력을 반환합니다.

Executing: program /usr/bin/ssh host destination_server, user root, command sftp
OpenSSH_9.2p1 Debian-2, OpenSSL 3.0.8 7 Feb 2023
debug1: Reading configuration data /home/username/.ssh/config
debug1: /home/username/.ssh/config line 5: Applying options for destination_server
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Executing proxy command: exec ssh -W destination_server:22 hop_server
debug1: identity file /home/username/.ssh/id_ecdsa type 2
debug1: identity file /home/username/.ssh/id_ecdsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.2p1 Debian-2
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.1
debug1: compat_banner: match: OpenSSH_7.1 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to destination_server:22 as 'root'
debug1: load_hostkeys: fopen /home/username/.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: [email protected]
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 
debug1: load_hostkeys: fopen /home/username/.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 'destination_server' is known and matches the ED25519 host key.
debug1: Found key in /home/username/.ssh/known_hosts:8
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: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: agent returned 1 keys
debug1: Will attempt key: ED25519 agent
debug1: Will attempt key: /home/username/.ssh/id_ecdsa ECDSA explicit
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: ED25519 agent
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /home/username/.ssh/id_ecdsa ECDSA explicit
debug1: Server accepts key: /home/username/.ssh/id_ecdsa ECDSA explicit
Authenticated to destination_server (via proxy) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: client_input_hostkeys: searching /home/username/.ssh/known_hosts for destination_server / (none)
debug1: client_input_hostkeys: searching /home/username/.ssh/known_hosts2 for destination_server / (none)
debug1: client_input_hostkeys: hostkeys file /home/username/.ssh/known_hosts2 does not exist
debug1: Sending environment.
debug1: channel 0: setting env LANG = "en_US.UTF-8"
debug1: Sending subsystem: sftp
debug1: client_global_hostkeys_prove_confirm: server used untrusted RSA signature algorithm ssh-rsa for key 0, disregarding
debug1: update_known_hosts: known hosts file /home/username/.ssh/known_hosts2 does not exist
debug1: pledge: fork
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2808, received 2776 bytes, in 0.2 seconds
Bytes per second: sent 14229.8, received 14067.6
debug1: Exit status 127
scp: Connection closed

관련 정보