Add user to sudoers

Q'center app, Helpdesk app
jkingma
Getting the hang of things
Posts: 92
Joined: Wed Oct 21, 2015 2:15 am

Add user to sudoers

Post by jkingma »

Hi!
For security reason I'd disable the standard admin user and created a new one in the Administrators user group. Yet this user is not allowed everthing on the system (swapoff for instance is denied and is allowed to Admin). Also it is not allowed to sudo.

How do I add a new administrator user to the sudoers? (there is no visudo available )
QNAP TS-453mini
Firmware: up to date
matiasiglesias
First post
Posts: 1
Joined: Fri Jun 12, 2020 9:45 pm

Re: Add user to sudoers

Post by matiasiglesias »

login to your Qnap via ssh with admin user

Code: Select all

ssh admin@your-nas-ip
edit /usr/etc/sudoers file

Code: Select all

vim /usr/etc/sudoers
and add the following line

Code: Select all

your-user-name ALL=(ALL) ALL
User avatar
OneCD
Guru
Posts: 12141
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Add user to sudoers

Post by OneCD »

Last time I checked, QTS doesn't use 'sudo'.

Can someone please confirm if there exists a [/usr/etc/sudoers] file on their NAS?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
dolbyman
Guru
Posts: 35248
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Add user to sudoers

Post by dolbyman »

OneCD wrote: Sat Jun 13, 2020 5:08 am Can someone please confirm if there exists a [/usr/etc/sudoers] file on their NAS?
I have that file .. yes (every single line commented out on my 853Bu)

actually this one is not commencted out

Code: Select all

## User privilege specification
##
admin ALL=(ALL) ALL
httpdusr ALL=(ALL) NOPASSWD:ALL
User avatar
OneCD
Guru
Posts: 12141
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Add user to sudoers

Post by OneCD »

Thanks @dm. :)

What firmware version is that?

Do you have a working ‘sudo’ binary too?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
dolbyman
Guru
Posts: 35248
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Add user to sudoers

Post by dolbyman »

OneCD wrote: Sat Jun 13, 2020 5:53 am Thanks @dm. :)

What firmware version is that?
4.4.2.1320
OneCD wrote: Sat Jun 13, 2020 5:53 am Do you have a working ‘sudo’ binary too?
sudoers is the only one in /usr/etc/
User avatar
OneCD
Guru
Posts: 12141
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Add user to sudoers

Post by OneCD »

Yup, but is ‘sudo’ present?

Code: Select all

which sudo

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
dolbyman
Guru
Posts: 35248
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Add user to sudoers

Post by dolbyman »

oh you meant the program that reads the config file .. lol

here:

Code: Select all

[~] # which sudo
/usr/bin/sudo
User avatar
OneCD
Guru
Posts: 12141
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Add user to sudoers

Post by OneCD »

dolbyman wrote: Sat Jun 13, 2020 7:10 am

Code: Select all

[~] # which sudo
/usr/bin/sudo
Hmm, so QTS now has 'sudo' ... nice! :geek:

I'll remove my suspicions from my first post.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
darioampuy
First post
Posts: 1
Joined: Tue Jun 23, 2020 2:28 am

Re: Add user to sudoers

Post by darioampuy »

the sudoers file is recreated by some script in the qnap each time the nas is restarted. unleast you find the script and modify it (with a potential brick in the next restart because a sintax error) you'll have to recreate the modification every time your nas is rebooted... you could do it with a cron script that adds the user to the sudo group
andypircher
New here
Posts: 8
Joined: Thu Apr 02, 2020 3:46 am

Re: Add user to sudoers

Post by andypircher »

I'm having the same problem.
Can someone please post a working solution for this?
User avatar
dolbyman
Guru
Posts: 35248
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Add user to sudoers

Post by dolbyman »

solution to add to sudo (and modify startup to make it "permanent") was already posted further up
dartheide
New here
Posts: 5
Joined: Sat Nov 12, 2016 7:19 pm

Re: Add user to sudoers

Post by dartheide »

0. Create your own username and edit the access permission for SSH in the QNAP controlpanel
1. Install Entware
2. Login as admin with ssh.
3. opkg update
4. opkg install sudo
5. Edit /opt/etc/sudoers and add "<yourusername> ALL=(ALL) ALL"
6. Logout and login with your own username
7. In the user directory add a file with the name ".profile" and add the line "export PATH=/opt/bin:$PATH"
8. logout and login DONE
paulchoe
New here
Posts: 2
Joined: Tue Jun 11, 2019 11:43 pm

Re: Add user to sudoers

Post by paulchoe »

Can you explain how you can install Entware in detail?
I tried to follow your steps, but I found it to be difficult to replicate.
It must be missing some intermediate steps...
User avatar
OneCD
Guru
Posts: 12141
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Add user to sudoers

Post by OneCD »

Hi Paul and welcome to the forum. :)
paulchoe wrote: Tue Aug 25, 2020 2:04 am Can you explain how you can install Entware in detail?
I tried to follow your steps, but I found it to be difficult to replicate.
It must be missing some intermediate steps...
I'm wondering if you really need the advice in this topic then? This topic is for those with some experience at the command shell - at least enough that they don't need to ask how to install Entware.

As you have asked, I see a big red-flag that you're probably trying to solve a problem the wrong way. ;)

May I ask: what are you trying to fix?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
Locked

Return to “NAS Management”