Samba
A Samba file server enables file sharing across different operating systems over a network. It lets you access your desktop files from a laptop and share files with Windows and macOS users.
Install samba on Gentoo Linux
Configure /etc/samba/smb.conf
- Example: Sharing folder,
/etc/samba/smb.conf
Disable printer sharing
By default Samba shares printers configured using CUPS.
If you do not want printers to be shared, use the following settings:
Block certain file extensions on Samba share
Setting this parameter will affect the performance of Samba, as it will be forced to check all files and directories for a match as they are scanned. Samba offers an option to block files with certain patterns, like file extensions.
This option can be used to prevent dissemination of viruses or to dissuade users from wasting space with certain files.
More information about this option can be found in smb.conf(5).
List public shares
The following command lists public shares on a server
Storing share passwords
Storing passwords in a world readable file is not recommended. A safer method is to use a
credentials file instead, e.g. inside /etc/samba/credentials
For the mount command replace username=myuser,password=mypass with credentials=/etc/samba/credentials/share
The credential file should explicitly readable/writeable to root
Restrict protocols for better security
By default, Samba versions prior to 4.11 allow connections using the outdated and insecure SMB1 protocol.
When using one these Samba versions, it is highly recommended to set server min protocol = SMB2_02 to
protect yourself from ransomware attacks. In Samba v4.11 and newer, SMB2 is the default min protocol,
so no changes are required there.
Clients using mount.cifs