Assalamu'alaykum warahmatullah wabarakatuh
Kali ini saya akan share cara membuat user setara root di redhat. Kalau gak salah semua tutorini berlaku juga di linux lainnya. Saya akan menggunakan 2 cara, yaitu menggunakan cara memasukkan ke group dan edit di hosts.
SERVER
1. Buat user dan masukkan ke group sudo yang sudah otomatis tersedia.
useradd usernamepasswd username
usermod -aG wheel username
usermod -aG wheel username
[root@node1 ~]# useradd ihsan
[root@node1 ~]# passwd ihsan
Changing password for user ihsan.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@node1 ~]# usermod -aG wheel ihsan
2. Lalu kita cek, apakah user ihsan tanpa sudo dapat hak akses root.
[root@node1 ~]# su - ihsan
Last login: Sat May 12 14:07:54 +07 2018 from 192.168.40.69 on pts/0
[ihsan@node1 ~]$ ls -la /root/
ls: cannot open directory /root/: Permission denied
3. Coba pake sudo.
[ihsan@node1 ~]$ sudo ls -la /root/
[sudo] password for ihsan:
total 104
dr-xr-x---. 4 root root 4096 May 15 06:30 .
dr-xr-xr-x. 18 root root 267 May 11 19:58 ..
-rw-------. 1 root root 1621 May 1 21:25 anaconda-ks.cfg
-rw-r--r-- 1 root root 0 May 15 06:30 autorelabel
-rw-------. 1 root root 22697 May 14 17:35 .bash_history
-rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
-rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc
-rw-r--r--. 1 root root 15080 Oct 3 2017 epel-release-latest-7.noarch.rpm
-rw-r--r--. 1 root root 15080 Oct 3 2017 epel-release-latest-7.noarch.rpm.1
-rw-r--r-- 1 root root 0 May 15 06:09 hasilnya.txt
-rw-------. 1 root root 55 May 3 22:03 .lesshst
-rw------- 1 root root 216 May 12 14:25 .mysql_history
-rw-r--r-- 1 root root 0 May 15 05:52 nyoba.txt
drwxr-----. 3 root root 19 May 2 19:04 .pki
-rw-------. 1 root root 1024 May 6 20:23 .rnd
drwx------. 2 root root 25 May 3 06:54 .ssh
-rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc
-rw-------. 1 root root 740 May 3 22:13 .viminfo
-rw-r--r--. 1 root root 302 May 3 22:10 .vimrc
HOSTS
1. Buat user baru dan buka /etc/sudoers.
useradd nyoba
passwd nyoba
nano /etc/sudoers
passwd nyoba
nano /etc/sudoers
2. Baris ke 93. Tambahkan user kita dibawah user root.
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
ihsan ALL=(ALL) ALL
root ALL=(ALL) ALL
ihsan ALL=(ALL) ALL
3. Lalu exit keluar semua user dan login lagi.
0 comments: