Search Posts

How to enable su(switch user) in Linux server

          su command is used to switch the current user to another user from SSH.If you are in the shell under your “username“, you can change it to another user (say root) using the su command.This is especially used when direct root login is disabled.

Step1:Login Server:-

Login to server via SSH click here  to know how to login and change port number

Step2:User Creation:-

The following command will add a new user called test to your Server.

[root@newdelhihosting ~]# useradd test
[root@newdelhihosting ~]# passwd test
Changing password for user test.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@newdelhihosting ~]#

Step3:Assign user to wheel group:-

[root@newdelhihosting ~]# nano /etc/group
wheel:x:10:test                                    

Save modified text and exit from group file

More about Nano Text Editor

Step4:Disable direct root access:-

[root@newdelhihosting /]# cd /etc/ssh
[root@newdelhihosting ssh]# nano sshd_config

Modify "#PermitRootLogin yes" to "PermitRootLogin no"

Save modified text and exit from group file.

Step5:Restart the service

[root@newdelhihosting ssh]# systemctl restart sshd.service
[root@newdelhihosting ssh]#

Step6:Jump to super user

login as: test
test@103.14.120.207's password:enter password here
Go to switch user by following command
[test@newdelhihosting ~]$ su -
Password:root password

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial

Enjoy this blog? Please spread the word :)