sumarsono.com
Take it with a grain of salt


Freebsd Install sudo Dan Menambahkan User Ke sudoers

Posted on

Aku memakai freeBSD 12

[email protected]:~ $ freebsd-version; uname -a
12.2-RELEASE
FreeBSD miniserver 12.2-RELEASE FreeBSD 12.2-RELEASE r366954 GENERIC  amd64
[email protected]:~ $ 

Aku setup dua user yakni root dan sumar, Ketika aku jalankan sudo muncul error:

[email protected]:~ $ sudo ifconfig
-sh: sudo: not found

FreeBSD by default memang tidak memasang binari sudo, oleh sebab itu perintah tersebut error. Lantas bagaimana cara install sudo di freeBSD 12?. sudo di freebsd dapat diinstall melalui ports collections. Untuk memsang sudo aku login ke console menggunakan akun root, kemudian menjalankan perintah berikut:

[email protected]:~ # cd /usr/ports/security/sudo/
[email protected]:~ # make install clean

Memasang paket dari ports collections akan memakan waktu yang tidak sedikit karena itu akan compile di mesin secara langsung. Semakin kentang spek mesin yang dipakai, semakin lama compile nya. Haha. Setelah selesai, binari sudo akan terpasang di /usr/local/bin/sudo

Selanjutnya, aku memasukan user sumar ke group wheel

[email protected]:~ # pw group mod wheel -m sumar

Selanjutnya, aku setting sudoers untuk group wheel tersebut

[email protected]:~ # vi /usr/local/etc/sudoers.d/wheel-group

# isinya
wheel ALL=(ALL) ALL

Terakhir, test apakah user sumar sudah bisa menjalankan perintah sudo:

[[email protected] ~]$ ssh [email protected]
Password for [email protected]:
Last login: Sat Jan  2 13:42:38 2021 from 192.168.1.31
FreeBSD 12.2-RELEASE r366954 GENERIC 

Welcome to FreeBSD!

[email protected]:~ $ sudo ifconfig
Password:
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
	ether 9c:8e:99:48:27:61
	inet 192.168.1.254 netmask 0xffffff00 broadcast 192.168.1.255
	media: Ethernet autoselect (100baseTX <full-duplex>)
	status: active
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
	inet 127.0.0.1 netmask 0xff000000
	groups: lo
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
[email protected]:~ $ 

Sukses.

Nah itu tadi caraku memasang sudo di freebsd dan menambahkan sudoers user di freebsd.