I recently encoutered the same issue as described here, namely after restoring a backup on a different device (Raspberry Pi) when trying to use
sudo with the admin user, I got the following error message:
user is not allowed to run sudo on mydomain. This incident will be reported.
It turned out I could not switch to the root account using
su and the root password either. So what I ended up doing was the following:
- Turning-off the server, taking out the sd-card and mounting it on my Linux laptop
- Then, I added my ssh public key to the root account by manually editing the
/root/.ssh/authorized_keysfile. I followed this tutorial to this aim (beware to edit the file on the SD card and not the one of the host computer).
- The next step was to activate root logging by ssh by setting
/etc/ssh/sshd_config, following the instructions here. This may have been unnecessary according to the doc, as I was on the same local network.
- Then, I unmounted the card, put it back to the Pi, started it again and logged in as root directly, not admin.
- From the root account, I added the admin user back to the sudo group with
usermod -a -G sudo admin.
- Then, I deactivated the ssh root login again (do not forget to restart the sshd service).
After this, I could use
sudo with the admin user again. Maybe there would have been a better way, though.