1

I am trying to create a user with su access on centos. I followed the instructions from this post. but NOTHING worked.

I want to login using su test_user

steps:

sudo adduser test_user (No prompt to set up password)

I tried su test_user (prompted for password) (pressed entered key - did not work)

then I deleted password

sudo passwd -d test_user
Removing password for user test_user.
passwd: Success

Then I tried

su test_user 
Password: (just enter key pressed)
su: Permission denied

NOTE: I also changed my sudoers file to reflect the following at the end of file /etc/sudoers as indicated in this post.

test_user ALL=(ALL) NOPASSWD:ALL

still nothing worked. Thanks

2 Answers2

4

OK, to be clear, su and sudo are completely different things. Adding test_user to your sudoers file is completely irrelevant for this use case.

su allows you to switch from one user to another, while sudo allow you to run a command as a different user. There's a subtle difference.

Having a passwordless account is horrible idea. Don't do it.

If you want to be able to switch from one account to another without affecting the other account's password, then just do:

$ sudo su - username

It goes without saying that your user account will need to be added to sudoers with the appropriate access to run the above command as root.

EEAA
  • 110,608
0

Create an user with empty password

sudo useradd test-user-0
echo test-user-0:U6aMy0wojraho | sudo chpasswd -e
su test-user-0

The password prompt still shows unfortunately.

But if you just hit enter without typing anything, and it logins as the user test-user-0.

The -e flags tells chpasswd that the password is already encrypted, and U6aMy0wojraho is the hash of the empty string.

Tested on Ubuntu 18.04.

BusyBox autologin

On the terminal at least, you don't need to create an user without a password to allow someone to not type their passwords everytime, hacking inittab a bit is enough: https://unix.stackexchange.com/questions/299408/how-to-login-automatically-without-typing-the-root-username-or-password-in-build