Trouble connecting with ssh key to hetzner docker server

@George
Hi George
I have tried to connect an existing Hetzner cloud server following the tutorial, but unfortunately I am unable to successfully complete the operation.

I can’t understand where I’m wrong

How did you connect successfully with ssh on the terminal what command did you use?

Was it with password or just ssh root@xx.xx.xx.xx ?

if I give the command ssh root @ XXXXXXX asks me for the password and after having entered it accesses the root

Well that might be the problem, you should connect passwordless to your server with just the ssh key.

Have you saved your ssh key in your user home folder .ssh as id_rsa?

What do you get if you do:

ssh root@xx.xx.xx.xx -i ~/.ssh/id_rsa

He always asks me for the password (which is correct anyway) and then connects
Note that once connected, if I do ls the ssh keys are displayed

You should be able to login with ssh key only without password.

So you should check if your key is i. The authorized_keys file on the server.

Maybe follow:

@George
I tried to redo everything from the beginning, but even if I don’t enter a password when creating a new key, the password is still required. But it raises a doubt in /Users/.ssh/ there are these files authorized_keys id_rsa id_rsa.pub known_hosts If I delete them all, maybe I can eliminate the password problem? And above all, is it not that by deleting them I cause problems for the other projects on Hetzner that have no problems?

Hold on, these files are in the wrong folder! In fact, these are not supposed to be uploaded to the VPS! They should be on your computer only

# On the VPS
ls ~/.ssh

On your Mac, use the command ssh-copy-id to copy your id_rsa.pub to the VPS

The contents of id_rsa.pub will be inserted in file ~/.ssh/authorized_keys if I’m not mistaken

Tank you, but Hetzner tutorial is this

Adding to Hetzner’s console won’t magically make it appear on your existing VPS. This only applies to new instances going forward, where you have to chance to automatically add your SSH key to your VPS upon deployment

You need to use ssh-copy-id to upload your SSH key to an existing VPS

I understand the concept, but not how it can be done
However, the problem seems to be primarily the presence of the password which should be eliminated, as George said

Ok,

You have an SSH key on your computer, it has two parts:

  • Private key - id_rsa
  • Public key - id_rsa.pub

Once the public key is uploaded to your VPS, it won’t ask you for a password to login.

You can install ssh-copy-id on your Mac with the following command:

brew install ssh-copy-id

On your Mac, you have to run the following command to upload your SSH key:

ssh-copy-id -i ~/.ssh/id_rsa.pub root@YOUR_VPS_IP

Let me know if you experience any struggles :slight_smile:

2 Likes

Fantastic it worked perfectly
Thank you very much

@George
After Mela’s suggestion, now I can create the project machine without receiving errors and I can also without errors set porttainer and traefik, confirm IP address and regenerate Security Key
However, I cannot use the other functions of the START, STOP, RESTART, KILL panel
Evidently there is still something wrong
And indeed a test page is not displayed

However, I cannot use the other functions of the START, STOP, RESTART, KILL panel

True, those functions aren’t available for imported generic servers.

You can use your hosting panel the execute those actions if needed.

Ok george
But unfortunately Wappler confirms the remote connection as a functioning, but then a simple index page is read correctly on local server but remotely not find the index file

Are you trying to deploy an existing project on the server? Maybe you should check if the right project name is used by clicking on the change:

image

For other errors - please post an separate topics.