키 인증을 사용하여 두 서버간에 SCP로 복사하는 방법은 무엇입니까? key. debug1: Found key in

SERVER1 및 SERVER2에 키 인증을 사용하여 SSH를 통해 로그인 할 수 있습니다. 그러나 두 서버간에 파일을 복사 할 수 없습니다. 왜? 그들 사이에 어떻게 복사 할 수 있습니까? (복사해야하는 데이터가 노트북 HDD보다 큽니다)

내 노트북은 Ubuntu 10.04 LTS를 실행하며 두 서버는 AIX 5300-10-02-0943입니다. 내 ~/.ssh/known_hosts노트북에있는 파일에는이 두 서버의 공개 키가 포함되어 있습니다. tsocks이 두 서버에 도달하려면 SSH 터널을 사용해야 하므로 사용합니다. 두 서버가 서로 핑할 수 있습니다.

[USER@NOTEBOOK ~] tsocks scp -v -i /home/USER/.ssh/id_rsa -p -r root@SERVER1:/PATH/TO/DIR root@SERVER2:/PATH/TO/DIR
Executing: /usr/bin/ssh '-v' '-x' '-oClearAllForwardings yes' '-n' '-l' 'root' 'SERVER1' 'scp -v -r -p' '/PATH/TO/DIR' 'root@SERVER2:/PATH/TO/DIR'
OpenSSH_5.3p1 Debian-3ubuntu7, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to SERVER1 [SERVER1] port 22.
debug1: Connection established.
debug1: identity file /home/USER/.ssh/identity type -1
debug1: identity file /home/USER/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-1024
debug1: identity file /home/USER/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.2p1+sas
debug1: match: OpenSSH_5.2p1+sas pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu7
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'SERVER1' is known and matches the RSA host key.
debug1: Found key in /home/USER/.ssh/known_hosts:59
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/USER/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 151
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.utf8
debug1: Sending command: scp -v -r -p /PATH/TO/DIR root@SERVER2:/PATH/TO/DIR
Executing: program /applications/ssh/5.20.15.0/bin/ssh host SERVER2, user root, command scp -v -r -p -t /PATH/TO/DIR
OpenSSH_5.2p1+sas, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to SERVER2 [SERVER2] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.2p1+sas
debug1: match: OpenSSH_5.2p1+sas pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: read_passphrase: can't open /dev/tty: No such device or address
Host key verification failed.
lost connection
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 1984, received 3848 bytes, in 0.3 seconds
Bytes per second: sent 6903.4, received 13389.2
debug1: Exit status 1


[USER@NOTEBOOK ~] tsocks scp -i /home/USER/.ssh/id_rsa -p -r root@SERVER1:/PATH/TO/DIR root@SERVER2:/PATH/TO/DIR
Host key verification failed.
lost connection
[USER@NOTEBOOK ~]



답변

이것은 수정하기가 매우 쉽습니다. 소스 서버는 대상 서버를 알지 못하므로 터미널을 열지 않았으므로 ID를 확인하도록 요청할 수 없습니다.

debug1: read_passphrase: can't open /dev/tty: No such device or address
Host key verification failed.
lost connection

따라서 소스 계정 / 서버에 로그인하고 dest 계정에 ssh (또는 scp)를 시도하고 호스트 키를 승인 한 후 login / scp를 취소하십시오. 복사 할 수 있어야합니다.

local $ ssh source@src-server
src-server $ ssh dest@dst-server
The authenticity of host 'destination (10.0.0.x)' can't be established.
RSA key fingerprint is 71:ec:c0:86:7f:b6:51:eb:76:c8:1f:2f:ba:0a:f4:20.
Are you sure you want to continue connecting (yes/no)? yes
dest@dst-server's password: ^C
src-server $ exit

local $ scp -r source@src-server:/path/to/files dest@dst-server:/path/to/files

그렇지 않은 경우 다음을 시도하십시오.

local $ scp -r -o "ForwardAgent=yes" source@src-server:/path/to/files dest@dst-server:/path/to/files

대상 서버에 액세스 할 수있는 SSH 키가 있고 소스 서버에 액세스 -o "ForwardAgent=yes"할 수 없는 경우 추가 를 사용하면 SSH 에이전트를 소스 서버에 전달하여 SSH 키를 사용하여 대상 서버에 연결할 수 있습니다.


답변

약간의 진단 : 이것으로부터

debug1: Sending command: scp -v -r -p /PATH/TO/DIR root@SERVER2:/PATH/TO/DIR
[...]
debug1: read_passphrase: can't open /dev/tty: No such device or address

나는 이런 식으로 작동한다고 의심합니다 (추측). scp로그를 가진 서버 간 복사 SERVER1scp파일을 보내기 위해 명령을 실행합니다 SERVER2. 따라서 발신자 (from SERVER1)는 자신을 인증해야합니다. 이제는 비대화 식이며 (아니요 /dev/tty) 암호문을 요구할 방법이 없기 때문에 실패합니다 .

열쇠 복사하는이 수단 SERVER1(아마이 문제를 (나는 …) 생각 고칠 수 (이 상황에서 가능한 경우 내가 말할 수 없습니다) 오히려 나쁜에는 암호 …이없는 경우를 )

편집 해결책은 다음과 같을 수 있습니다. sshfs보내려는 파일에 액세스 scp하고 sshfs-mounted 디렉토리 에서 파일을 보내십시오 . 이것은 필요한 상호 작용을 제공하고 (위의 추측이 맞다면) 모든 키를 로컬로 유지해야합니다.


답변

나는 이것을 시도했고 두 시스템 사이에 약간의 차이점이 있습니다.

  • SSH 키를 추가하여 실행중인 SSH 에이전트가 있습니다 ( ssh-add)
  • 기본적으로 ssh-agent 전달이 활성화되어 있습니다

다음을 시도하십시오 :

ssh-add
scp -v -o "ForwardAgent=yes" -p -r root@SERVER1:/PATH/TO/DIR root@SERVER2:/PATH/TO/DIR


답변

-3scp 옵션 을 사용하고 싶을 때 노트북을 통해 트래픽을 전달합니다.

[USER@NOTEBOOK ~] scp -3 root@SERVER1:/PATH/TO/DIR root@SERVER2:/PATH/TO/DIR


답변

ssh에 대해이 옵션을 시도하십시오.

-o StrictHostKeyChecking=no
-o UserKnownHostsFile=.ssh/known_hosts [OPTIONAL]

필자의 경우 postgreSQL의 SP 내부에서 ssh와 연결하려고합니다. 첫 번째 시도 실패 :

pc_ubuntu_db=# SELECT command('ssh -q -v admin@10.30.134.26 hostname');
debug1: Server host key: RSA 0a:28:83:72:d7:7d:89:93:96:a1:1b:e2:f9:22:85:62
debug1: read_passphrase: can't open /dev/tty: No such device or address
        Host key verification failed.

문제의 원인 : know_host에 쓸 수 없습니다

pc_ubuntu_db=# SELECT command('ssh -v -o StrictHostKeyChecking=no -i admin@10.30.134.26 hostname');
debug1: Server host key: RSA 0a:28:83:72:d7:7d:89:93:96:a1:1b:e2:f9:22:85:62
Warning: Permanently added '10.30.134.26' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
...
Transferred: sent 2672, received 2040 bytes, in 0.0 seconds
Bytes per second: sent 214358.6, received 163657.0
debug1: Exit status 0

다음 연결 출력 :

debug1: Server host key: RSA 0a:28:83:72:d7:7d:89:93:96:a1:1b:e2:f9:22:85:62
debug1: Host '10.30.134.26' is known and matches the RSA host key.
debug1: Found key in /var/lib/postgresql/.ssh/known_hosts:3
debug1: ssh_rsa_verify: signature correct

성공 !!!


답변