Samba is software that enables file and printer sharing between Windows and UNIX. Not only Linux and Mac, but also smart devices like Android and iOS can connect to the server.
NFS is a well-known non-Samba file server. For NFS, refer to Building an NFS server on Arch Linux.
samba Install the package.
# pacman -Syu samba
Create /etc/samba/smb.conf
. The following is an example of a configuration file that shares / data / share / public
.
/etc/samba/smb.conf
[global]
#It is case sensitive.
case sensitive = yes
#Do not try DNS resolution if the NetBIOS name is not found.
dns proxy = no
# 192.168.0.0/24 and 127.0.0.0/8 (Loopback)Allow access from.
hosts allow = 192.168.0. 127.
#Prohibit access from the root user.
invalid users = root
#Set the name of the log file.%m is replaced with the NetBios name.
log file = /var/log/samba/%m.log
#Specifies the maximum size of the log file in KB.
max log size = 10000
#Disable SMB1 and use SMB2 or later.
server min protocol = SMB2
#Operate in standalone mode, where authentication and resource management are completed on this server.
server role = standalone server
#Set the server description.%h is replaced with the host name.
server string = Samba File Server on %h
#Workaround for Mac issues with creating weird permissions ignoring create masks.
unix extensions = no
#The server sendsfile()Use this to optimize performance.
use sendfile = yes
#Set the name of the workgroup appropriately.
workgroup = WORKGROUP
#Define a shared file server accessible to all Samba users.
[public]
#Specify the file path on the server.
path = /data/share/public
#Authenticate using your username and password.
security = user
#Allows writing as well as reading to shared files.
writable = yes
Create a directory to share if it does not already exist. I set the permissions to 777 so that other users can access it.
# mkdir -p /data/share/public
# chmod 777 /data/share/public
Open TCP ports 137, 138, 139, 445. The following is an example of iptables configuration.
/etc/iptables/iptables.rules
-A INPUT -m state --state NEW -m tcp -p tcp --syn -m multiport --dports 137,138,139,445 -j ACCEPT
Start smbd and nmbd.
# systemctl start smb nmb
Also, set smbd and nmbd to start automatically after a system reboot.
# systemctl enable smb nmb
Use a Linux user to access Samba. Create a Linux user in advance, such as by using the ʻuseraddcommand. However, you must set a Samba-specific password separate from the Linux user password. Use the
pdbedit` command to set the password.
# pdbedit -a -u name
There is also a way to synchronize your Linux login password with your Samba password, but this is not covered here.
Mac
Click "Move" and "Connect to Server (Command + K)" to display a dialog. Enter an address such as nfs: //192.168.0.16/public
.
However, this will cause it to be unmounted when the system is rebooted. To mount it automatically, select the above mount point from "System Preferences", "Users and Groups", "Login Items", and "+".
Android
Download the appropriate filer application for Samba from the Google Play store. I'm using CX File Explorer (https://play.google.com/store/apps/details?id=com.cxinventor.file.explorer&hl=ja). You can access the Samba server in CX File Explorer by following these steps:
Network
tab and click the+
button.Remote
tab and select SMB
.host`` user name
password
and click the ʻOK` button.Recommended Posts