How to connect with ssh with different droplet/vps

May 19, 2015 2.2k views
Linux Basics Security

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.

2 Answers

Hi,

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:

#HOST1
Host host_prod
        HostName 100.100.100.100
        Port 22
        User ubuntu
        IdentityFile ~/any_folder/private_ssh_file

#HOST2
Host host_test
        Hostname 200.200.200.200
        Port 22
        User ubuntu 
        IdentityFile ~/any_folder/private_ssh_file

Check:

  • 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.

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.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!