Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scp host key verification failed for remote to remote copy [closed]

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?

like image 275
necromancer Avatar asked Mar 20 '12 21:03

necromancer


People also ask

How do I fix host key verification failed?

To fix this error, we need to delete the offending key from the “known_hosts” file present in our system in “. ssh” directory. The error gives you the remote server's IP address and the line number on which the key is stored in the “known_hosts” file.

How do I remove host key verification?

You need to create a ~/. ssh/config file and disable strict host key checking by adding the content. This will disable host checking for all hosts you connect to. Rather than disabling host check for all Host “*”, it would be safer to specify a particular host.

What does host key verification failed mean?

This error occurs when the target server you are trying to SSH into has been rebuilt or had it's RSA key changed since the last time you connected to it.

What is host key verification?

In host key checking, ssh automatically maintains and checks a database containing identification for all hosts it has ever been used with. Host keys are stored in ~/. ssh/known_hosts in the user's home directory. Additionally, the /etc/ssh/ssh_known_hosts file is automatically checked for known hosts.


2 Answers

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

like image 190
Travis Stevens Avatar answered Sep 19 '22 17:09

Travis Stevens


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.

like image 31
dAm2K Avatar answered Sep 19 '22 17:09

dAm2K