0

After installing DevStack, I was forced to put my user as root and gain access. I did that and now I would like to undo it. I removed the line from visudo but still no success. What want like to reverse is the following: Using Ubuntu and login with my user ("USER") and when i open my terminal i execute the sudo -i command, I was asked to enter the password to have root access. After the changes I made with DevStack, when I execute the sudo -i command, I'm not asked for any password, I just have root access (and I don't like this). Is there any way to change this back so when I execute the sudo -i command I will be asked for a password?

As to add the file of visudo

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
  • sudo means: Do things as if you were root. So do you get asked for password if you type su? If not, I'd know how to "solve" this. (Besides, the -i option is only for instructing the shell to also read the resource files, e. g. .profile / .login etc. Which is to say that sudo ought to show the same (erroneous) behavior with or without -i.) – syntaxerror Nov 23 '14 at 20:56
  • 1
    Remove the files 50_stack_sh, cinder-rootwrap, neutron-rootwrap, nova-rootwrap from /etc/sudoers.d and it will start asking you for the password again. – talonx Jul 30 '15 at 5:31
  • That work ! and i delete this files from other location that appear too but thanks man ! :D – user3523605 Oct 2 '15 at 10:25
2

If you want to be allowed to run commands as root, but be prompted to enter your own password, then edit the sudo configuration by running the visudo program. This brings up your favorite text editor to edit the sudo configuration file. Look for the line that authorizes you to run commands as root and remove the text NOPASSWD: from that line. Save the file and exit the editor.

If you don't want to be allowed to run commands as root without entering the root password, then follow the same procedure as above, but remove the line instead of just removing NOPASSWD: from it. Then, to run commands as root, use su instead of sudo and type the root password. Make sure that you know the root password before doing this!

You may be allowed to run commands as root via sudo either because some rule allows your user (a line starting with your username) or because some rule allows a group that you're a member of (a line starting with a percent sign and the group name, e.g. %admin …). If you want to remove yourself from that group, run deluser username groupname, e.g. deluser alice admin. Changing group membership has no effect on your current session, it takes effect the next time you log in.

Note that if sudo asked you for a password, it won't ask you again for the next few minutes (IIRC the default is 15 minutes on Ubuntu). Depending on the configuration, sudo may keep a separate password delay per terminal or a single one per user.

  • There is no line where the "NOPASSWD:" is ... above iv change the question as i put the visudo file as a result of what i have. – user3523605 Nov 24 '14 at 15:20
  • @user3523605 With this configuration, sudo does ask you for a password (but if you used it recently it won't ask you again for the next 15 minutes). – Gilles Nov 24 '14 at 16:58
  • 1
    No i have not use recently and that is the problem .. everything is ok ( by the book ) but i think we are missing something that this think wont work. Any other suggestion where can i change this. And in the visduo file i have one line where my user was there like this below the root line: ivan ALL=(ALL:ALL) ALL i have remove this line but still nothing still same problem. When i put sudo -i im going directly without asking for password in root mode. – user3523605 Nov 24 '14 at 18:40
  • @user3523605 You're probably in the sudo or admin group. – Gilles Nov 24 '14 at 18:56
  • Yes i think I am. But it was always in that group. As Administrator always ask me for password when i go to root. This is what i have in /etc/passwd ivan:x:1000:1000:Ivan,,,:/home/ivan:/bin/bash – user3523605 Nov 25 '14 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.