Skip to content

Instantly share code, notes, and snippets.

@iahim
Last active December 10, 2022 23:29
Show Gist options
  • Save iahim/f62b70083f220f1c907dd154de0f7c5f to your computer and use it in GitHub Desktop.
Save iahim/f62b70083f220f1c907dd154de0f7c5f to your computer and use it in GitHub Desktop.
# ========================
# SERVER SIDE
# ========================
apt install samba
mkdir -p /share/samba-all
# create user admin with password samba
adduser --home /share/users/admin --no-create-home --shell /usr/sbin/nologin --ingroup sambashare admin
chown admin:sambashare /share/samba-all/
chmod 2770 /share/samba-all/
# add samba admin user (with password samba) and enable it
smbpasswd -a admin
smbpasswd -e admin
# used for a better organisation
groupadd admins
usermod -G admins admin
mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
vim /etc/samba/smb.conf
[global]
server string = samba_server
server role = standalone server
interfaces = lo eth0
bind interfaces only = yes
disable netbios = yes
smb ports = 445
log file = /var/log/samba/smb.log
max log size = 10000
[share-all]
path = /share/samba-all
browseable = yes
read only = no
force create mode = 0660
force directory mode = 2770
valid users = admin @admins
# OPTIONAL
# force user = www-data
# force group = www-data
# test samba config
testparm
# run samba daemon
systemctl start smbd.service
# =======================
# CLIENT SIDE
# =======================
apt-get install smbclient cifs-utils -y
vim /root/.secret-samba
username=admin
password=samba
chmod 600 /root/.secret-samba
mkdir -p /share/all
cat /etc/fstab
//192.168.1.21/share-all /share/all cifs _netdev,credentials=/root/.secret-samba, 0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment