server1
두 대의 서버 가 있고 server2
.
ssh root@server1
키 로그인을 사용 하거나 이를 통해 ssh root@server2
내 컴퓨터에서 두 서버 모두에 SSH를 통해 연결할 수 있습니다 .
server1
에서 으로 파일을 복사하고 싶습니다 server2
.
제한 요인:
- 어느 서버에도 SSH 개인 키를 저장하고 싶지 않습니다. 또한 비밀번호를 묻는 메시지도 표시되어서는 안 됩니다.
- 내 컴퓨터를 통해 데이터를 라우팅하고 싶지 않습니다. 따라서 이
-3
옵션은 사용할 수 없습니다.
이것은 내가 얻는 결과입니다.
$ scp -o StrictHostKeyChecking=no root@server1:~/script.sh root@server2:~/
Permission denied (publickey).
lost connection
자세한 출력:
$ scp -v -o StrictHostKeyChecking=no root@server1:~/script.sh root@server2:~/
Executing: /usr/bin/ssh '-x' '-oClearAllForwardings=yes' '-n' '-v' '-o' 'StrictHostKeyChecking=no' '-l' 'root' '--' 'server1' 'scp -v' '~/script.sh' 'root@server2:~/'
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /home/johndoe/.ssh/config
debug1: /home/johndoe/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to server1 [11.22.33.44] port 22.
debug1: Connection established.
debug1: identity file /home/johndoe/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/johndoe/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to server1:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
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: Server host key: ecdsa-sha2-nistp256 SHA256:dS7************************************************Dw
debug1: Host 'server1' is known and matches the ECDSA host key.
debug1: Found key in /home/johndoe/.ssh/known_hosts:9
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:gw*******************************bc /home/johndoe/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 277
debug1: Authentication succeeded (publickey).
Authenticated to server1 ([11.22.33.44]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = C.UTF-8
debug1: Sending command: scp -v ~/script.sh root@server2:~/
Executing: program /usr/bin/ssh host server2, user root, command scp -v -t ~/
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to server2 [55.66.77.88] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 pat OpenSSH* compat 0x04000000
debug1: Authenticating to server2:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
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: Server host key: ecdsa-sha2-nistp256 SHA256:pj***************************************eA
debug1: Host 'server2' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
lost connection
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2780, received 7200 bytes, in 1.1 seconds
Bytes per second: sent 2501.1, received 6477.7
debug1: Exit status 1
노트:
authorized_keys
각 서버의 파일에 공개 키를 구성했습니다.- 내 개인 키는 내 컴퓨터의 디렉토리에만 저장됩니다
id_rsa
..ssh
- 내 컴퓨터의 운영 체제
server2
는 Ubuntu 18.04이고 위의 운영 체제server1
는 Ubuntu 16.04입니다.