0

I am running Centos 8.

I have used various instructional documents, such as the below:

https://www.cyberciti.biz/faq/how-to-sudo-without-password-on-centos-linux/

in an attempt to be able to ssh to an account, and then get to root without having to use a password. I am accessing my machine via passwordless ssh with a key that requires a passphrase.

Once I have logged in, with my account, I want to be able to sudo to root without a password.

Is that even possible?

What I have done is logged in as root (Which DOES require my account password) and then:

visudo

And added this line here for the account for "Keith".

keithchegwin ALL=(ALL) NOPASSWD:ALL

Now, for "good measure" I have started sshd again, and logged back in as keithchegwin fully expecting to be able to do:

su root

With no password, but it still asks for a password for the account I am logged in as. I want it to stop!

What am I doing wrong? Thanks.

I did see his other question here, but that refers to running a specific script or program, not accessing an account with no password so I do not think this is a duplicate:

How to run a specific program as root without a password prompt?

2 Answers2

1

sudo and su are two different commands, and do different things.

su on its own won't do passwordless.

With your setup, you could do something like sudo su and it won't ask for a password. Or, more simply sudo -i or sudo -s.

0

You can try sudo su root. Also, you only want to enter root privileged shell, the next command is worked too: sudo -s. Difference between both, sudo su root inherits all currently environment variables, sudo -s equals sudo "$SHELL". For example, in sudo -s, if your default shell is /usr/bin/zsh, you'll be the same as sudo "/usr/bin/zsh".

sakkke
  • 193