Conecting to a VPS with ssh keys

Hi there,

I’m having a real nightmare of a time trying to get my client cube to connect to my VPS using ssh keys. Ive been scouring youtube and the net for tutorials and I’ve followed a few but I always keep running into problems.

I have no problems getting in with passwords.

At first I followed a mental outlaw tutorial on youtube. This didn’t work and also he gets you to disable password authentication in it as well so it locked me out of the VPS. There were no error messages, it just hung.

I then started looking at internet sights. Along the way I checked and confirmed that the public key was pushed to the VPS and it was in authorized_keys. At one attempt I got an error saying unauthorized access (public key) which I read about and found out that the public key want present and that I need to use an -i flag and specify a path.

Well now I can get into it with a password but I have no idea if the ssh keys are involved at all and im reluctant to disable password auth in case I lock myself out for umpteenth time and have to reinstall the VPS OS.

I’m using Debian on the VPS btw.

I’d really appreciate some help in making this work. I’ll bet it’s something simple and obvious I’ve overlooked

Hi, this is not related to Qubes OS, but here is a quick how to use keys with SSH

  • run ssh-keygen in your client, this will create both ~/.ssh/id_rsa (the private key that should never leave the system) and ~/.ssh/id_rsa.pub (the public key that must be put in the ~/.ssh/authorized_keys of the remote servers where you want to connect
  • run ssh user@vps-hostname to connect, ssh will automatically use the keys with the default names like id_rsa

You must connect once with the password to add the public key of course (this can be provisioned automatically in most hosting companies on which you put the list of public keys to allow on your servers so they use them when creating a VPS).

If you want to know how it connected, add -vv to the ssh command line, there will be a line telling that id_rsa was used. Also, if it does not ask for password, this mean the key was used.

thanks and apologies if this isn’t the right place. I’m getting to the end of my rope lol. I’ll try wiping it again and starting afresh with those ideas in mind

Make split ssh by the way

That’s a nice thing on Qubes OS, but it’s really one step further in term of complexity :+1:

1 Like

You’ll want to make sure your SSH key is stored in the right qube and that your ssh command is running from there. A common approach is to keep your private key in a dedicated vault or ssh qube and use a disposable or networked qube to connect.

You can copy the public key to your VPS using:

ssh-copy-id user@your-vps

Or manually add your public key to ~/.ssh/authorized_keys on the VPS.


Soax Review