1、首先安装samba
yum install samba
2、查看安装信息
rpm -qi samba,正常显示如下
3、配置内核相关参数
ulimit -n 16384 && vim /etc/security/limits.conf,增加内容如下:
* - nofile 16384
4、关闭防火墙和selinux服务或者在iptables里放开445和139端口,并重启iptables服务
smbpasswd -a 增加用户(要增加的用户必须以是系统用户)
smbpasswd -d 冻结用户,就是这个用户不能在登录了
smbpasswd -e 恢复用户,解冻用户,让冻结的用户可以在使用
smbpasswd -n 把用户的密码设置成空.
systemctl stop firewalld.service 和setenforce 0 (如果不关闭,则可能无权限创建文件)
chkconfig –level 35 iptables off 或者 systemctl disable firewalld.service (永久关闭)
关闭selinux:
/etc/sysconfig/selinux里设置 SELINUX=disabled 即可,reboot生效。
5、配置smb.conf
配置smb.conf ,vim /etc/samba/smb.conf
smb.conf 配置内容
[global]
netbios name = cmcc1
server string = Linux Samba Server TestServer
security = user #在samba4中 share 和 server已经被禁用
map to guest =Bad User
[cmcc]
path = /opt/cmcc
writeable = yes
browseable = yes
guest ok= yes
注意:在samba4中 share 和 server已经被禁用,需要用security = user 和map to guest =Bad User来实现无密码访问目录
[skdkjzz_inspur]
path = /home/inspur
writeable = yes
valid users = skdkjzz
6、启动smb服务
systemctl start samba.service
systemctl restart samba.service
systemctl enable samba.service
7、查看smb状态
systemctl status samba.service
8、测试smb连通性
smbclient -L localhost -U <smbuser>
正常显示如下:
9、添加开机启动smb
chkconfig --level 345 smb on
10、无密码登录smb.conf实例:
[global]
max log size = 50
workgroup=WORKGROUP
display charset = UTF-8
unix charset = UTF-8
dos charset = cp936
security = share
passdb backend = tdbsam
load printers = yes
cups options = raw
[files]
comment = parent
path = /root
writeable = yes
public = yes
guest ok = yes
browseable = yes
create mask = 0777
directory mask = 0777
有密码登录:
[skdkjzz_inspur]
path = /home/inspur
writeable = yes
valid users = skdkjzz
(smbpasswd -a skdkjzz)
11、其他参考