SCP:2つの(リモート)ホスト間で転送できません。

SCP:2つの(リモート)ホスト間で転送できません。

1 つはパスワード認証を使用し、もう 1 つは使用しません。

# scp -i ~user/.ssh/id_rsa_test01 user@test01:/tmp root@test02:/path/to/test01_bkp/
ssh: Could not resolve hostname test02: Name or service not known
lost connection
# host test02
test02.example.com has address 1.2.3.99

-vvを使用してください:

Executing: /usr/bin/ssh -x -oClearAllForwardings=yes -n -v -v -i /home/user/.ssh/id_rsa_test01 -l user -- test01 scp -v /tmp root@test02:/path/to/test01_bkp/
OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug2: resolving "test01" port 22
debug2: ssh_connect_direct
debug1: Connecting to test01 [1.2.3.6] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa_test01 type 0
debug1: identity file /home/user/.ssh/id_rsa_test01-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2
debug1: match: OpenSSH_7.2 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to test01:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],[email protected],aes256-ctr,aes128-ctr
debug2: ciphers stoc: [email protected],[email protected],aes256-ctr,aes128-ctr
debug2: MACs ctos: [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
debug2: MACs stoc: [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1510/3072
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:<stripped>
debug1: Host 'test01' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:12
debug2: bits set: 1510/3072
debug2: set_newkeys: mode 1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /home/user/.ssh/id_rsa_test01 RSA SHA256:<stripped> explicit
debug2: pubkey_prepare: done
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/user/.ssh/id_rsa_test01 RSA SHA256:<stripped> explicit
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: /home/user/.ssh/id_rsa_test01 RSA SHA256:<stripped> explicit
debug1: Authentication succeeded (publickey).
Authenticated to test01 ([1.2.3.6]:22).
debug2: fd 4 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug1: Sending env LANG = POSIX
debug2: channel 0: request env confirm 0
debug1: Sending env LC_CTYPE = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug1: Sending command: scp -v /tmp root@test02:/path/to/test01_bkp/
debug2: channel 0: request exec confirm 1
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: read<=0 rfd 4 len 0
debug2: channel 0: read failed
debug2: channel 0: chan_shutdown_read (i0 o0 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug2: channel 0: input drain -> closed
debug2: channel 0: rcvd ext data 107
Executing: program /usr/bin/ssh host test02, user root, command scp -v -t /path/to/test01_bkp/
debug2: channel 0: written 107 to efd 6
debug2: channel 0: rcvd ext data 49
OpenSSH_7.2p2, OpenSSL 1.0.2p-fips  14 Aug 2018
debug2: channel 0: written 49 to efd 6
debug2: channel 0: rcvd ext data 56
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: channel 0: written 56 to efd 6
debug2: channel 0: rcvd ext data 61
debug1: /etc/ssh/ssh_config line 25: Applying options for *
debug2: channel 0: written 61 to efd 6
debug2: channel 0: rcvd ext data 70
ssh: Could not resolve hostname test02: Name or service not known
debug2: channel 0: written 70 to efd 6
debug2: channel 0: rcvd ext data 16
lost connection
debug2: channel 0: written 16 to efd 6
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: chan_shutdown_write (i3 o1 sock -1 wfd 5 efd 6 [write])
debug2: channel 0: output drain -> closed
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug2: channel 0: rcvd close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3304, received 3784 bytes, in 0.1 seconds
Bytes per second: sent 29509.6, received 33796.7
debug1: Exit status 1

SLES 15SP2(openssh-8.1p1実行)

答え1

あなたの(以前の)バージョンがホストにホストに直接コピーするようにscp指示したいようです。この場合、最初のホストは2番目のホストのアドレスを確認する方法を知りません。test01test02

次のフラグを使用して、接続がローカルクライアントを通過するように強制できます-3

scp -3 -i ~user/.ssh/id_rsa_test01 user@test01:/tmp root@test02:/path/to/test01_bkp/

(この回答を読む他の人のために、-3最新バージョンには対応するフラグは必要ありません。インストールされているバージョンについては、scpマニュアルページ()を確認してください。)man scp

関連情報