I am trying to migrate my web application from my old vps (amazon EC2) to my new droplet, following this DO guide.
I am stuck at copying the SSH keys from the old VPS to the new one.
I logged in as ‘ubuntu’ user to my EC2 instance (ubuntu 18.04 OS) and did
ssh-keygen -t rsa -b 4096 -v.
After trying to use the
ssh-copy-id command the first time, I saw a
Connection timed out error.
I then allowed traffic to port 22 on my droplet as explained in this DO comment by doing
sudo ufw allow 22/tcp from the droplet.
However, I tried the
ssh-copy-id command again but this time I got a
Permission denied (publickey) error.
The exact command I run from the old VPS is (excluding my IP):
I also tried specifying a different user (as amazon EC2 comes with a “ubuntu” user while the droplet has “root”) but I got the same error.
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.
I solved my problem by following the suggestions of @LindsayBSC with a slight change.
Here is what I did to solve the problem. If somebody could possibly explain why I had to do this I’d be thankful.
In the NEW droplet VPS
In the OLD EC2 VPS
Check that you can connect to the NEW VPS from this (OLD) VPS:
In the NEW droplet VPS
Repeat all the steps inverting the changes to
Hello @alexgeorgiev and thanks for the feedback. I tried with (excluding public IP)
, but I still got
root@<DROPLET_PUBLIC_IP>: Permission denied (publickey).
It’s a problem of the droplet settings I suppose, as that is the one complaining about the permissions.
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Sign up now
You can follow this article:
The command you can use to copy the key to the new machine:
This should do the work for you! Let me know how it goes.