scp host key verification failed for remote to remote copy

55,921

Solution 1

It works. Your problem is the SSH authentication between user@remote and user@remote. If it's the same user on the same server and you are using RSA authentication, you have to append the public key (~/.ssh/id_rsa.pub) into ~/.ssh/authorized_keys of the user itself.

Pay attention to name resolution too. In your case "remote" can be a server name that make sense to your client, but could not make sense from the remote point of view. Use the server IP (if the server is not behind nat) or set a common server name into /etc/hosts on your client and server machine: "remote" should be resolvable from your client and your server machine.

Solution 2

Check out the option:

-3 : Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. Note that this option disables the progress meter.

This option became available in OpenSSH 5.7

Solution 3

"It is important to note that SCP cannot be used to remotely copy from the source to the destination when operating in password or keyboard-interactive authentication mode, as this would reveal the destination server's authentication credentials to the source." http://en.wikipedia.org/wiki/Secure_copy#Remote_to_remote_mode

Try using key-based authentication to pull off a remote to remote scp.

Share:
55,921
necromancer
Author by

necromancer

Updated on January 08, 2020

Comments

  • necromancer
    necromancer over 4 years

    scp foo user@remote:bar works fine

    scp user@remote:foo bar works fine

    scp user@remote:foo user@remote:bar fails with error:

    Host key verification failed.
    lost connection
    

    I am guessing this is because scp disallows remote to remote copy (between two different remote hosts or the same remote host) because it is inefficient to channel the data from point A to point L to point B rather than directly from point A to point B.

    Is that the right rationale for why it doesn't work? How come the command-line usage instructions in the manual does not document it? Or is it just that the specific scp on my Ubuntu distribution is trying to be paternal?

  • necromancer
    necromancer over 12 years
    i was using key-based authentication, the answer is to give credentials for remote to talk to remote (per previous answer)
  • necromancer
    necromancer over 12 years
    thanks - i understand now. it is the same user and same remote server.
  • dAm2K
    dAm2K over 12 years
    COOL to see how much granularity information level Wikipedia has reached!!
  • Worldcrafter
    Worldcrafter over 12 years
    Agreed. Wikipedia is becoming an excellent supplement to *nix man pages
  • user1338413
    user1338413 over 11 years
    doesnt work for me. same situation (same user and same remote server). the key is appended and im using the server IP. from local to remote and back work fine.
  • dAm2K
    dAm2K over 11 years
    try with ssh -vvv to enable some debug messages and try to check why it is not working for you
  • KCD
    KCD almost 10 years
    If you don't have 5.7+ and you don't want host1 going direct to host2 or you want rsync features try dir=`mktemp -d` && cd $dir && rsync -avz user1@host1:~/source . && rsync -avz . user2@host2:~/dest && rm -rvf $dir
  • user1943442
    user1943442 over 9 years
    This has made my life MUCH easier!
  • tjmehta
    tjmehta almost 9 years
    This works for scp between user1@remote1 and user2@remote2.