Nethserver 8 root ssh login

Hi,

I would like to connect to NS8 with ssh, but I can’t, I get an error message:

ssh root@ns8.mydomain.lan
root@ns8.mydomain.lan: Permission denied (gssapi-keyex,gssapi-with-mic).

It seems that you need a certificate for ssh. I created a public key on the client, but I can’t copy it to NS8 because ssh doesn’t connect!

I tried to enable PermitRootLogin yes in /etc/ssh/sshd_config and use password instead of certificate, but it doesn’t work.

That’s why I still can’t upload the public key to the NS8 with scp!

Can someone help me to remotely connect to NS8 as root with ssh?

Thanks for help

Hi @steve

Unless you used a prefab VM for NS8, you are the one who sets the root password during the installation ofthe base OS used to install NS8, and what options it offers.
I change that BEFORE even installing NS8 over the plain Debian I install.

No issues with this.

My 2 cents
Andy

1 Like

Hi @Andy_Wismer

I downloaded the NS8 Rocky Linux qcow2 image and run it on Proxmox. I set the admin and root passwords during installation.

I found that a certificate is needed for ssh, but even though I created one, I can’t upload it because there is no sshh… The catch-22…

Why not run your own install? It only takes a few minutes!
I did that for Debian.

I want my VMs exactly the way I want them, not fiddle with other peoples SSH preferences or whatever.

No issues!

My 2 cents
Andy

1 Like

I’m trying to find a machine for testing and I’m going to put NS8 on it because the proxmox server is far from me…

1 Like

Yes, root user needs a SSH key to log in. You can install one by creating a personal account member of the wheel group. The full procedure is documented here: Installation — NS8 documentation

As alternative, provide a cloud-init disk image with the SSH key. This might seem rather complex, but I wish to document it too. Card NethServer · GitHub

I suggest to not change the default SSH configuration manually.

1 Like

@davidep

I added a user (steve) to the wheel group and set his password. I tried to connect to NS8 with steve using ssh, but it doesn’t work:

“ssh steve@ns8.mydomain.lan
steve@ns8.mydomain.lan: Permission denied (gssapi-keyex,gssapi-with-mic).”

It seems that the user steve also needs a certificate for ssh. How do I make a certificate on the client and upload it to NS8?

Does your access to the console, let you cut/paste the key.

Can you sftp out from the VPS to where you generated the key and pull it instead of trying to push.

Cheers.

Hi,

I managed to solve the problem with difficulty. The solution was as follows.

By default, NS8 only allows the use of ssh with a certificate. To do this, a certificate must be created on the client and it must be uploaded and configured for use on the NS8.

This is problematic if e.g. NS8 runs on Proxmox or a remote VPS, because there is no direct console availability (NS8 is not included), and the outputs displayed on the Proxmox console cannot be copied with copy-paste.

The solution is further complicated by the fact that in this case the NS8 only has one LAN interface for connecting to the Internet, there is no second LAN interface for the local network, instead there is only a dummy LAN interface. Therefore, you can proceed as follows to set up ssh.

Access via RSA keys, widely used for security, is a real alternative to password-based login, NS8 uses this solution. In this type of authentication, the client generates a private key and its corresponding public key, which is installed on the NS8 to uniquely authenticate the client.

To create a public key on the client, the key pair must first be generated with the ssh-keygen command:

$ ssh-keygen

Once done, the ssh-keygen command creates two files: the client’s private ey, which cannot be shared with anyone (id_rsa) and the sharable public key (id_rsa.pub), this will have to be uploaded to the NS8.

As a next step, according to the NS8 documentation, create a user (steve) as a member of the wheel group and give him a password (don’t want to ssh as root!). You can do this if you log in as root on the NS8 VM console on the Proxmox interface.

$ useradd -G wheel username 
$ passwd username

Log out of NS8 on the Proxmox VM console and log in with the user you just created. Create a .ssh directory in the user home directory, enter the directory and create an authorized_keys file:

$ mkdir .ssh

$ cd .ssh

$ touch authorized_keys

On the NS8 server, run the following command to download the public key from the client to the server:

$ scp userofclient@client_IP_address:/home/userofclient/.ssh/id_rsa.pub 
/home/userofns8/.ssh/id_rsa.pub

If necessary, set the user as owner on the uploaded id_rsa.pub file.

With the echo command, you could add the public key to the authorized_keys
file, but this will not work here, because the output of the displayed file cannot be copied on the Proxmox console.

Instead, copy the contents of the id_rsa.pub file into the authorized_keys file:

$ cp .ssh/id_rasa.pub .ssh /authorized_keys

Restart the sshd service:

$ sudo systemctl restart sshd.service

After that, you can successfully connect to NS8 with ssh.

In the case of multiple clients, additional concatenation of id_rsa.pub with the authorized_keys file with the echo command above works because the output of the ssh console can already be copied…

I hope this helps anyone with a similar problem…

2 Likes

This isn’t correct, even assuming you’re using the provided VM image. It requires public/private key authentication, but not a certificate. SSH certificate usage is rare and wouldn’t be part of a preconfigured OS image.

@danb35 you are absolutely right.

I think it’s clear from the description what it’s about…

The first two sentence is not precise enough, it would read exactly like this:

By default, NS8 only allows ssh with a public key. To do this, a public key must be created on the client and it must be uploaded and configured for use on the NS8.

Instead of a certificate, the public key should be understood everywhere, since the description is about the creation of keys, not about the creation of certificates…

Thanks for bringing this to my attention.