On my centos 7 vps server, to secure my server I disabled root login via ssh. I created a new user called erdem and login with that user via ssh. After I login via ssh with user erdem, I would like to switch to root user with su command or su -s command. When I do that I get this error:
-bash: /usr/bin/su: Permission denied
How can I give permission to user called erdem so I can switch with su or su -s command to root.
The output of ls -l /usr/bin/su
:
-rwsr-x--- 1 root wheel /usr/bin/su
I tried to add the user into wheel group but it still gives the same error.
I used bellow command
gpasswd -a erdem wheel
Solved: I needed to logout and login again.
sudo -s
. Doesn’t it work for you ? – LL3 Apr 12 '19 at 16:06su
is also a valid means to become root, particularly ifsudo
is not yet installed, or the newly-created non-root user is not yet insudoers
. OP, can you please add the output of the following to your question:ls -l /usr/bin/su
– DopeGhoti Apr 12 '19 at 16:13su
expects the target user's password (root in this case).sudo
expects the password of the user executing the command (yours).su
on some systems can only be executed by users in particular groups (wheel
on BSD, for example), but I'm unsure how this works on CentOS. – Kusalananda Apr 12 '19 at 16:14su
orsudo
and addresses the possibility that you used the wrong password.su
asks for the root password,sudo
asks for your password. – Kusalananda Apr 12 '19 at 16:19wheel
group and thus is not allowed to runsu
. It is also apparently not in any group allowed by yoursudo
configuration either. How did you create that user ? – LL3 Apr 12 '19 at 16:24wheel
group, you will need that user to log out and log back in again to refresh its group memberships. – DopeGhoti Apr 12 '19 at 16:29