Difference between revisions of "SAMBA: Membuat User untuk samba"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) (New page: Sumber: https://help.ubuntu.com/community/How%20to%20Create%20a%20Network%20Share%20Via%20Samba%20Via%20CLI%20%28Command-line%20interface/Linux%20Terminal%29%20-%20Uncomplicated,%20Simple%...) |
Onnowpurbo (talk | contribs) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
sudo apt-get update | sudo apt-get update | ||
sudo apt-get install samba | sudo apt-get install samba | ||
+ | |||
+ | atau di ubuntu >16.04 | ||
+ | |||
+ | sudo apt update | ||
+ | sudo apt -y install samba cifs-utils | ||
+ | |||
+ | |||
+ | ==Password samba== | ||
+ | |||
+ | Username yang digunakan adalah username di linux. | ||
Set password untuk user di Samba | Set password untuk user di Samba | ||
Line 13: | Line 23: | ||
+ | Jika <user_name> belum ada, kita perlu menambahkan dengan | ||
+ | |||
+ | sudo adduser <user_name> | ||
+ | |||
+ | Jika ingin agar username tidak bisa akses ke shell dapat dibuat menggunakan perintah | ||
+ | |||
+ | sudo useradd USERNAME --shell /bin/false | ||
+ | |||
+ | |||
+ | ==Setup folder== | ||
+ | |||
+ | Buat folder untuk sharing user tersebut | ||
+ | |||
+ | sudo mkdir /home/<user_name>/<folder_name> | ||
+ | sudo chown <user_name> /home/<user_name>/<folder_name> | ||
+ | sudo chown :<user_name> /home/<user_name>/<folder_name> | ||
+ | |||
+ | Misalnya | ||
+ | |||
+ | sudo mkdir /home/tamu/share | ||
+ | sudo chown tamu /home/tamu/share | ||
+ | sudo chown :tamu /home/tamu/share | ||
+ | |||
+ | |||
+ | Alternatif lain, dapat sembarang folder, misalnya | ||
+ | |||
+ | mkdir /mnt/share | ||
+ | chmod -Rf 777 /mnt/share | ||
+ | chown -Rf nobody.nogroup /mnt/share | ||
+ | |||
+ | |||
+ | ==Setup smb.conf== | ||
+ | |||
+ | Edit | ||
+ | |||
+ | sudo nano /etc/samba/smb.conf | ||
+ | |||
+ | Isi dengan | ||
+ | |||
+ | security = user | ||
+ | |||
+ | [<folder_name>] | ||
+ | path = /home/<user_name>/<folder_name> | ||
+ | valid users = <user_name> | ||
+ | read only = no | ||
+ | |||
+ | Misalnya | ||
+ | |||
+ | [share] | ||
+ | path = /home/tamu/share | ||
+ | valid users = tamu | ||
+ | read only = no | ||
+ | |||
+ | Untuk banyak user, dalam menggunakan parameter | ||
+ | |||
+ | valid users = root bin daemon adm sync shutdown \ | ||
+ | halt mail news uucp operator | ||
+ | |||
+ | |||
+ | |||
+ | ==Restart== | ||
+ | |||
+ | sudo service smbd restart | ||
+ | |||
+ | Test parameter | ||
+ | |||
+ | sudo testparm | ||
+ | |||
+ | |||
+ | ==Akses ke Share di SAMBA== | ||
+ | sudo apt-get install smbclient | ||
+ | # List all shares: | ||
+ | smbclient -L //<HOST_IP_OR_NAME>/<folder_name> -U <user> | ||
+ | # connect: | ||
+ | smbclient //<HOST_IP_OR_NAME>/<folder_name> -U <user> | ||
Latest revision as of 08:33, 13 December 2019
Install Samba
sudo apt-get update sudo apt-get install samba
atau di ubuntu >16.04
sudo apt update sudo apt -y install samba cifs-utils
Password samba
Username yang digunakan adalah username di linux.
Set password untuk user di Samba
sudo smbpasswd -a <user_name>
Ini akan di simpan di /etc/samba/smbpasswd
Jika <user_name> belum ada, kita perlu menambahkan dengan
sudo adduser <user_name>
Jika ingin agar username tidak bisa akses ke shell dapat dibuat menggunakan perintah
sudo useradd USERNAME --shell /bin/false
Setup folder
Buat folder untuk sharing user tersebut
sudo mkdir /home/<user_name>/<folder_name> sudo chown <user_name> /home/<user_name>/<folder_name> sudo chown :<user_name> /home/<user_name>/<folder_name>
Misalnya
sudo mkdir /home/tamu/share sudo chown tamu /home/tamu/share sudo chown :tamu /home/tamu/share
Alternatif lain, dapat sembarang folder, misalnya
mkdir /mnt/share chmod -Rf 777 /mnt/share chown -Rf nobody.nogroup /mnt/share
Setup smb.conf
Edit
sudo nano /etc/samba/smb.conf
Isi dengan
security = user
[<folder_name>] path = /home/<user_name>/<folder_name> valid users = <user_name> read only = no
Misalnya
[share] path = /home/tamu/share valid users = tamu read only = no
Untuk banyak user, dalam menggunakan parameter
valid users = root bin daemon adm sync shutdown \ halt mail news uucp operator
Restart
sudo service smbd restart
Test parameter
sudo testparm
sudo apt-get install smbclient
# List all shares: smbclient -L //<HOST_IP_OR_NAME>/<folder_name> -U <user>
# connect: smbclient //<HOST_IP_OR_NAME>/<folder_name> -U <user>