How to connect with ssh with different droplet/vps

I have created 2 droplet, the first one is for production and second one is for testing, so I can connect to the first server/droplet that I have created using ssh key. but when I tried to connect to the second droplet/server, it said “Host key verification failed” how do I connect to the second droplet using my ssh key?

so I have 2 ssh key and two droplet.

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.

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.

I have found my own solution, I tried to login to second server with password sent to my email and then copy my ssh key via terminal, and now I can log in in to two server at the time without password.


Do you have two public and private keys in some folder, right?

Can you configure a .config file in your ~/.ssh folder to connect multiples hosts in a simple command, example:

In your home directory (/home/my_user) look for a folder named “.ssh”. Haven’t? create:

mkdir .ssh

Navigate to the folder:

cd .ssh

Create a config file:

touch .config

Edit him with your preferred text editor:

nano .config

Put the code, something like this:

Host host_prod
        Port 22
        User ubuntu
        IdentityFile ~/any_folder/private_ssh_file

Host host_test
        Port 22
        User ubuntu 
        IdentityFile ~/any_folder/private_ssh_file


  • if your servers are allowed to accept external connections on port 22.
  • if the username is the same of this example.
  • the correct folder to the private key.