I had to instantiate a droplet from a snapshot of another droplet to recover some files I managed to delete. I logged into the new Droplet (lz2), created an ssh key pair, and copied and pasted the id_rsa.pub
key contents to the authorized_keys
file on the orignal Droplet. I was able to ssh to it after that without issue.
But try as I might, I could not get scp
or rsync
to work. They would just copy to the local host. I tried invoking it several different ways:
rmann@lz2:~$ scp nginx.tgz lz1:
rmann@lz2:~$ scp nginx.tgz lz1:ng.tgz
rmann@lz2:~$ scp nginx.tgz rmann@lz1:ng.tgz
rmann@lz2:~$ scp nginx.tgz <lz1’s IP address>:ng.tgz
All of them resulted in ng.tgz
being created in ~rmann
on lz2
. For the life of me I can’t figure out what was happening.
I ended up copying the file down to my laptop from lz2
and back up to lz1
.
Any idea why it wouldn’t copy from one Droplet to the other, but also not give me an error, isntead copying to the local machine?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey!
When you’re using
scp
to copy files from one host to another, the syntax should specify the source and destination clearly. If you’re executing the command fromlz2
and want to copy a file tolz1
, you should specify the user and host for the destination along with the full path. Ifrmann
is your username on both droplets andlz1
is the hostname or IP address of the destination droplet, the command should look like this:Or, if you want to use the IP address of
lz1
, it would be:This command tells
scp
to copynginx.tgz
to the/home/your-user/
directory onlz1
, saving it asng.tgz
.If these commands still result in the file being copied to the local machine (lz2), it’s highly unusual behavior for
scp
. Ensure that the hostname or IP address forlz1
is correct and reachable. If there’s any confusion about the hostnames, using the IP address can eliminate any potential DNS or host file misconfigurations.Also, using the
-v
flag for verbose output can help diagnose the issue, as it will provide detailed information about thescp
process and where it might be going wrong.Let me know how it goes!
Best,
Bobby
Heya @jetforme,
Okay, if you can SSH from one droplet to the other then you have access between them. From where did you run SCP? You’ll need to enter one of the Droplets(it doesn’t matter which, it would matter only to the command) and SCP the files to or from the other.
Now, let’s assume you have SSHed to Droplet 1 and you need to copy files from Droplet 2 to Droplet 1.
Here is how it should work
username
with your username on Droplet 2,droplet2_ip
with Droplet 2’s IP address,/path/to/remote/file
with the file’s path on Droplet 2, and/local/droplet1/path
with the path on Droplet 1 where you want the file to be copied to. That should do the trick.