Add a
user with administrative privileges that can ssh into the server and switch to
on root user using sudo.
In this
article, we are using the user name linuxcnf and will add in sudoers with full
privileges.
To
create a new user type the following command:
[root@linuxcnf
~]# useradd linuxcnf
[root@linuxcnf
~]#
|
Verify
the user ID details:
[root@linuxcnf
~]# id linuxcnf
uid=1001(linuxcnf)
gid=1001(linuxcnf) groups=1001(linuxcnf)
[root@linuxcnf
~]#
|
Set the
password for the user linuxcnf
[root@linuxcnf
~]# passwd linuxcnf
Changing
password for user linuxcnf.
New
UNIX password:
Retype
new UNIX password:
passwd:
all authentication tokens updated successfully.
[root@linuxcnf
~]#
|
Add user
in sudoers file, use the following command:
[root@linuxcnf
~]# visudo /etc/sudoers
|
Add the
below line in the file:
Linuxcnf ALL=(ALL) ALL
|
To ensure
login sudo privilege, SSH to the server with the linuxcnf user:
[root@linuxcnf
~]# ssh linuxcnf@192.168.43.107
linuxcnf@192.168.43.107's
password:
Last
login: Wed May 2 10:23:39 2018 from 192.168.43.103
[linuxcnf@linuxcnf
~]$
|
Switch
with root user:
[linuxcnf@linuxcnf
~]$ sudo su -
[sudo]
password for linuxcnf:
[root@linuxcnf
~]#
|
Verify
the logged user:
[root@linuxcnf
~]# whoami
root
|
It’s
done!!!
No comments:
Post a Comment