0

I am trying to download a directory from my cloud server to my local, using scp, with the following:

scp -i ./.ssh/mykey.pem -r -p [email protected]:/var/lib/mongodb 127.0.0.1:/var/lib/mongod

admin is of course the remote, for which I need to key, while 127.0.0.1 is the local.

I receive however the error message:

Host key verification failed.
lost connection

If I try to connect through ssh to my server using ssh -i ./.ssh/mykey.pem [email protected] it does work.

Could anyone point me to what I am doing wrong?

2 Answers 2

2

For copying to the local server, you don't need the 127.0.0.1:. Just this will do:

scp -i ./.ssh/mykey.pem -r -p [email protected]:/var/lib/mongodb /var/lib/mongod

With the 127.0.0.1:, scp makes another SSH connection to the server at 127.0.0.1 and acts as if it was copying between two remotes. The SSH server at 127.0.0.1 might be failing host key verification.

0
1

From Man page,

scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2

So when you are using 127.0.0.1 at last portion, scp recognized that as host2. So then scp will try to logged in at 127.0.0.1 host with current username, based on the identity file (./.ssh/mykey.pem) and returns error, may be because there is no information about host2. So just following will work fine,

$scp -i ./.ssh/mykey.pem -r -p [email protected]:/var/lib/mongodb /var/lib/mongodb

OR

$cd /var/lib/mongodb
$scp -i ./.ssh/mykey.pem -r -p [email protected]:/var/lib/mongodb .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .