Allow root access without passwd

44,565

Solution 1

Warning; not tested because I think it's not such a great idea, even for a VM (bad habits are difficult to remove...).

I think this is a PAM thing (PAM=pluggable authentication modules).

In /etc/pam.d there are all the PAM configuration files that tell the system how to do the authentication of users. Now, the module that check for the passwords "unix style" is pam_unix.so, in which man page you can find among the options:

  nullok
       The default action of this module is to not permit the user access
       to a service if their official password is blank. The nullok
       argument overrides this default and allows any user with a blank
       password to access the service.

   nullok_secure
       The default action of this module is to not permit the user access
       to a service if their official password is blank. The nullok_secure
       argument overrides this default and allows any user with a blank
       password to access the service as long as the value of PAM_TTY is
       set to one of the values found in /etc/securetty.

So I suspect is a matter of finding all the occurences of pam_unix.so in the files above, and add the option nullok (or change the nullok_secure to nullok) to the entries.

According to this post the file should be /etc/pam.d/common-auth --- but I am not sure about this because in Ubuntu the VC are in the /etc/securetty list so the null password for root should work from there (although not from a terminal emulator), and the SO states it doesn't work.

So a bit of experimentation will be needed ;-).

Solution 2

try

sudo -s

It will ask your password to login in as root.

then use passwd to change the root password.

if you are not in sudo user

type

sudo visudo

add this line in the last

<username> ALL=NOPASSWD: ALL

then ctrl+x to exit then ,y to save the changes

then try again sudo -s it will login to root without asking password

Share:
44,565

Related videos on Youtube

Déjà vu
Author by

Déjà vu

[email protected] Linux &amp; Mac.

Updated on September 18, 2022

Comments

  • Déjà vu
    Déjà vu over 1 year

    Have a VirtualBox Ubuntu guest (14.04) used for the sake of testing only.
    The root user has its own password, so I can login as root in a separate terminal (su -), or directly from a login session (eg after Ctrl-Alt-F4).

    $ su -
    Password: <current root password>
    # echo Works!
    

    Since it is a VB testing system, and the root user does not need any security, I want to be able to su - or login as root quickly, i.e. without root having a password.

    So, tried as root

    # passwd -d root
    

    to remove the root password - it seems to work according to /etc/shadow (::)

    root::16304:0:99999:7:::
    

    but when trying to su -, it asks for a password, I just press enter (no password)

    $ su -
    Password: 
    su: Authentication failure
    

    but it doesn't su.

    There has to be a setting somewhere to allow root to login/su without password.
    Where would that be?

  • Elder Geek
    Elder Geek over 9 years
    I agree that this is a bad idea.....
  • Déjà vu
    Déjà vu over 9 years
    Indeed it's in /etc/pam.d/common-auth, line with pam_unix.so, change nullok_secure to nullok (and in any other required auth files). Thanks for considering privileged users as adults, and providing a solution while warning the less experienced readers.
  • Déjà vu
    Déjà vu over 9 years
    Where did you see sudo in the question?