transfer files between droplets? Permission denied (publickey)

Hi I am trying to transfer files from 1 droplet to another (they are in the same region). I found some articles about doing it using the VPC private IP.

I’ve tried a few things and I haven’t been able to get it working yet.

Please can someone give some guidance?

This is what I’ve tried on the droplet with the files:

  • Logged in using Putty to SSH and entered this cmd
  • scp -r /html/wp-content/testingthis root@


scp -r /html/wp-content/testingthis root@
The authenticity of host ' (' can't be established.
ED25519 key fingerprint is SHA256:FingerPrintStringHere.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? FingerPrintStringHere
Warning: Permanently added '' (ED25519) to the list of known hosts.
root@ Permission denied (publickey).
lost connection

I then tried

  • ssh-keygen
  • Enter file in which to save the key (/root/.ssh/id_rsa): vpcfile

I then copied the contents of the and pasted it into the remote destination droplet:

  • nano .ssh/authorized_keys

And then did this on both droplets:

  • sudo service sshd restart

I then tried this cmd again:

  • scp -r /html/wp-content/testingthis root@

And got this result:

root@ Permission denied (publickey).
lost connection

I’ve tried following the instructions from these sites:

Please can someone advise on how to get this working?

Thank you

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
April 27, 2023
Accepted Answer

Hi there,

As you’ve generated your SSH key with a non-standard name, the scp command is failing to find it. You need to specify the correct private key file when using scp:

  1. Make sure you have the correct private key file (in this case, vpcfile) on the source droplet.

  2. Use the -i option with scp to specify the private key file. Run the following command on the source droplet:

scp -i /root/.ssh/vpcfile -r /html/wp-content/testingthis root@

Replace /root/.ssh/vpcfile with the actual path to your vpcfile private key if this is not the one.

This command should now work without any permission issues.

Let me know how it goes!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel