I am reading this tutorial, and trying to create a new user with root privileges and then block root access via ssh in a CentOS 7 server. The problem is that the new user is blocked from doing root actions like
nano /etc/sudoers. Also, I seem unable to remove the block of root login. So my pre-existing open root session is the only access I have to root functionality until it terminates. How can I successfully add root permissions to the newuser? And how can I successfully turn on/off root login?
Here is what I have so far:
/etc/sudoers, I have:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
newusername ALL=(ALL) ALL
Note that I edited
/usr/sbin/visudo did not work.
/etc/ssh/sshd_config I have
PermitRootLogin yes because I want to turn root login back on until I can get newusername to have root privileges. Also, the last line of the file is
I then typed
systemctl reload sshd.service because
/etc/init.d/sshd reload threw an error on
The problem is that currently
newusername does not have
root privileges and yet I am not able to login as
root either. So my pre-existing connection as
root is my only way of controlling the machine.
I was able to give the new user
sudo privileges with
gpasswd -a newusername wheel, but I still cannot log in as root even though I have
PermitRootLogin yes in
/etc/ssh/sshd_config. How can I get
CentOS 7 to respect the settings in
/etc/ssh/sshd_config? I should be able to turn root login on and then off again at will, and have the settings actually work.