將 Linux 服務器目錄通過 Samba 共享,在 Windows 上映射為本地磁盤盤符(如 Z:),實現無縫文件操作體驗。
yum install samba samba-client samba-common system-config-samba
useradd www
mkdir -p /data/www
chmod 777 /data/www
chown -R www:www /data/www
cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
vim /etc/samba/smb.conf
[global]
server string = Samba Server
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
[web]
workgroup = www
netbios name = www
path = /data/www
browseable = yes
writeable = yes
smbpasswd -a www
systemctl start smb nmb
systemctl enable smb nmb
Win+R 輸入:\\192.168.8.32\web,輸入用戶名 www 及密碼,勾選「記住憑據」。
\\192.168.8.32\webnet use Z: \\192.168.8.32\web /user:www 密碼 /persistent:yes
| 需求 | 配置 |
|---|---|
| 多用戶隔離 | 創建多系統用戶,valid users 限制共享訪問 |
| 只讀共享 | writeable = no、force create mode = 0444 |
| 大文件傳輸優化 | socket options = TCP_NODELAY SO_RCVBUF=65536 SO_SNDBUF=65536 |
| 防止斷連 | keepalive = 30、Windows 端 net config server /autodisconnect:-1 |