2.5 KiB
2.5 KiB
Samba Share
A Samba share lets you access files on this machine over the network (Windows SMB protocol).
<> - Is used to mark that you need to fill that in
Initial Setup (one-time)
1. Install Samba
sudo pacman -S samba # Arch
sudo apt install samba # Debian/Ubuntu
2. Create a Samba user
The samba password is separate from your system password.
sudo smbpasswd -a <username>
3. Edit /etc/samba/smb.conf
Example config for sharing the Projects folder:
[global]
workgroup = WORKGROUP
server string = %h
map to guest = Bad User
log file = /var/log/samba/%m.log
max log size = 50
socket options = TCP_NODELAY
[Projects]
comment = Projects
path = /home/honney/Projects
browseable = yes
read only = no
writable = yes
valid users = honney
create mask = 0664
directory mask = 0775
4. Start Samba
sudo systemctl enable --now smb
5. Allow Samba through the firewall
sudo firewall-cmd --add-service=samba --permanent
sudo firewall-cmd --reload
Or with ufw:
sudo ufw allow samba
Mounting the share on another Linux machine
Install cifs-utils:
sudo pacman -S cifs-utils # Arch
sudo apt install cifs-utils # Debian/Ubuntu
Mount manually:
sudo mount -t cifs //<IP>/Projects </path/to/mount> -o username=honney,vers=3.0
/etc/fstab entry
//<IP>/Projects </path/to/mount> cifs username=honney,password=<password>,vers=3.0,nofail,uid=1000,gid=1000,iocharset=utf8,file_mode=0664,dir_mode=0775 0 0
Or with a credentials file (more secure):
//<IP>/Projects </path/to/mount> cifs credentials=</path/to/.smbcredentials>,vers=3.0,nofail,uid=1000,gid=1000,iocharset=utf8,file_mode=0664,dir_mode=0775 0 0
Credentials file (~/.smbcredentials):
username=honney
password=<password>
chmod 600 ~/.smbcredentials
Find the IP of the Samba server
ip a | grep inet
List available shares
smbclient -L //<IP> -U honney
Troubleshooting
Check if Samba is running:
sudo systemctl status smb
View active connections:
sudo smbstatus
Test the config for errors:
testparm
Restart Samba after config changes:
sudo systemctl restart smb
Access from Windows
Open File Explorer and type:
\\<IP>\Projects
Then log in with the samba username and password.