Linux安装配置samba
yum -y -q update
yum install -y -q samba samba-client samba-common cifs-utils
smb.conf的配置例子如下
cat>/etc/samba/smb.conf<<EOF
[global]
workgroup = WORKGROUP
server string = x200
dns proxy = no
# interfaces = eth0
syslog = 0
browsable = yes
map to guest = bad user
nt pipe support = no
encrypt passwords = true
passdb backend = tdbsam
obey pam restrictions = yes
unix password sync = no
netbios name = MY_SHARE_SERVER
#== Share Definitions ===
[share]
path = /opt/share_folder
valid users=share_user
directory mask = 0755
create mask = 0664
writable = yes
guest ok = no
read only = no
public = no
EOF
配置好smb.conf后需要创建目录和设置用户密码
useradd share_user #创建Linux用户
mkdir /opt/share_folder #创建目录
chown -R share_user:share_user /opt/share_folder #设置文件夹归属权限
chmod 755 /opt/share_folder #设置文件夹读写权限
smbpasswd -a share_user #设置密码
最后启动smb后测试。
建立一个无home目录最低权限隶属于www组的用户myshare (一些面板或者脚本已有www, www-data之类的可以跳过)
useradd -M myshare -g www -s /sbin/nologin
使用tdbsam管理samba帐号
pdbedit -a username #新建Samba账户 pdbedit -x username #删除Samba账户 pdbedit -v username #显示账户详细信息 pdbedit -L #列出Samba用户列表,读取passdb.tdb数据库文件 pdbedit -Lv #列出Samba用户列表详细信息
none