How to add user to sudoers

I downloaded and installed the latest NCP and enabled SSH through the NCP panel. I am able to log in but I can’t do anything with sudo because the account I added is not in sudoers. How can I add an account to sudoers?

With which method did you install NCP? Please run ncp-report and add the output here. Or, check nc-info from :4443 interface or ncp-config and share that here.

I installed NCP by writing the img file to a SD.

System Info
‣ You should run Lets Encrypt for trusted encrypted access

‣ You should use nc-datadir to move your files to your plugged in USB drive

‣ You should enable automount to use your plugged in USB drive

NextCloudPi version	v1.50.3
NextCloudPi image	NextCloudPi_RaspberryPi_v1.50.3.img
OS	Debian GNU/Linux 11. 5.10.92-v8+ (aarch64)
automount	no
USB devices	sda
datadir	/var/www/nextcloud/data
data in SD	yes
data filesystem	ext2/ext3
data disk usage	2.3G/14G
rootfs usage	2.3G/14G
swapfile	/var/swap
dbdir	/var/lib/mysql
Nextcloud check	ok
Nextcloud version	24.0.5.1
HTTPD service	up
PHP service	up
MariaDB service	up
Redis service	up
HPB service	up
Postfix service	up
Internet check	ok
public IPv4	68.101.xxx.xx
public IPv6	not found
Port check 80	closed
Port check 443	closed
IP	192.168.1.xx
gateway	192.168.1.1
Interface	eth0
certificates	none
NAT loopback	no
Uptime	50min

Thanks, here is a guide to add user to sudoers. There are lots available online for adding sudo user in Debian.

with usermod, I got

usermod: Permission denied.
usermod: cannot lock /etc/passwd; try again later.

Seems like one has to add pi as user when enabling SSH from the NCP panel. The reason is that even though pi is removed as the default user, it is still in the sodoers.

Unsure, never encountered this issue ever (when using ncp). I’ll let someone else advise. You should be able to boot into your boot menu and change the root user password in Debian since you don’t know it.

Hi sn2018,

please use the web-ui and activate SSH for user pi as described in

(Its currently possible via Web-UI only!!)

This will activate the user pi again (which is part of sudoers)

Afterwards you can logon with user pi from terminal/console (physically keyboard/display connected to your device) as well as using ssh.

Crazy workaround, however the only one i am aware of for now.

Best regards
schoetju

I believe that problem will be related with this:

Thank you for confirming. See my previous post.

If you flash the card with using Raspberry Pi Imager you can add the user correctly as explained in the Headless setup of the post.

Yes, that will work too as long as you add pi in userconf or userconf.txt