CentOS 7配置samba
(以下内容均来自网络学习)
root用户执行
1、使用yum -y install samba samba-client samba-common安装Samba
rpm -qi samba可以查看samba版本信息
[root@MiWiFi-R1CM-srv samba]# rpm -qi samba
Name : samba
Epoch : 0
Version : 4.2.10
Release : 6.2.el7_2
Architecture: x86_64
Install Date: Tue 19 Jul 2016 03:26:55 AM CST
Group : System Environment/Daemons
Size : 1895784
License : GPLv3+ and LGPLv3+
Signature : RSA/SHA256, Fri 24 Jun 2016 04:12:11 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : samba-4.2.10-6.2.el7_2.src.rpm
Build Date : Fri 24 Jun 2016 02:38:45 AM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.samba.org/
Summary : Server and Client software to interoperate with Windows machines
Description :
Samba is the standard Windows interoperability suite of programs for Linux and Unix.
[root@MiWiFi-R1CM-srv samba]#
2、设置开机启动:Name : samba
Epoch : 0
Version : 4.2.10
Release : 6.2.el7_2
Architecture: x86_64
Install Date: Tue 19 Jul 2016 03:26:55 AM CST
Group : System Environment/Daemons
Size : 1895784
License : GPLv3+ and LGPLv3+
Signature : RSA/SHA256, Fri 24 Jun 2016 04:12:11 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : samba-4.2.10-6.2.el7_2.src.rpm
Build Date : Fri 24 Jun 2016 02:38:45 AM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.samba.org/
Summary : Server and Client software to interoperate with Windows machines
Description :
Samba is the standard Windows interoperability suite of programs for Linux and Unix.
[root@MiWiFi-R1CM-srv samba]#
# systemctl enable smb.service
3、查看是否设置成功# systemctl status smb.service
4、启动samba服务# systemctl start smb.service
5、再次查看启动状态
# systemctl status smb.service
[root@MiWiFi-R1CM-srv samba]# systemctl status smb.service● smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2016-07-19 03:32:36 CST; 12min ago
Main PID: 27455 (smbd)
Status: "smbd: ready to serve connections..."
CGroup: /system.slice/smb.service
├─27455 /usr/sbin/smbd
├─27460 /usr/sbin/smbd
└─27601 /usr/sbin/smbd
Jul 19 03:32:36 MiWiFi-R1CM-srv systemd[1]: Starting Samba SMB Daemon...
Jul 19 03:32:36 MiWiFi-R1CM-srv systemd[1]: smb.service: Supervising process 27455 which is not our child. We'll most likely not n... exits.
Jul 19 03:32:36 MiWiFi-R1CM-srv systemd[1]: Started Samba SMB Daemon.
Jul 19 03:32:36 MiWiFi-R1CM-srv smbd[27455]: [2016/07/19 03:32:36.184968, 0] ../lib/util/become_daemon.c:124(daemon_ready)
Jul 19 03:32:36 MiWiFi-R1CM-srv smbd[27455]: STATUS=daemon 'smbd' finished starting up and ready to serve connections
Hint: Some lines were ellipsized, use -l to show in full.
[root@MiWiFi-R1CM-srv samba]#
6、配置配置文件
进入目录:
# cd /etc/samba
备份:# cp smb.conf smb.conf.backup
修改smb.conf文件,找到“[homes]”,修改以下设置:[global]
log file = /var/log/samba/log.%m
load printers = yes
cups options = raw
server string = Samba Server Version %v
writeable = yes
force directory mode = 777
force create mode = 777
workgroup = MYGROUP
security = user
create mode = 777
passdb backend = tdbsam
max log size = 50
log file = /var/log/samba/log.%m
load printers = yes
cups options = raw
server string = Samba Server Version %v
writeable = yes
force directory mode = 777
force create mode = 777
workgroup = MYGROUP
security = user
create mode = 777
passdb backend = tdbsam
max log size = 50
新版的samba放在smb.conf最后是无效的
7、添加用户
# smbpasswd -a username
如果出现bash: smbpasswd: command not found,就是没有安装samba-client了附: smbpasswd命令的常用方法
smbpasswd -a 增加用户(要增加的用户必须以是系统用户)
smbpasswd -d 冻结用户,就是这个用户不能在登录了
smbpasswd -e 恢复用户,解冻用户,让冻结的用户可以在使用
smbpasswd -n 把用户的密码设置成空.要在global中写入 null passwords -true
smbpasswd -x 删除用户
8、selinux设置
# getsebool -a | grep samba
# setsebool -P samba_enable_home_dirs on
9、防火墙,使用新的防火墙firewall添加就可以,比iptables更方便
# firewall-cmd --list-services
# firewall-cmd --permanent --add-service=samba
# firewall-cmd --reload
# firewall-cmd --list-services
由于redhat7开始,iptables被firewalld代替了,所以使用firewalld的方法关于firewalld的说明,可以看fedora官网介绍
10、重启samba服务
# systemctl restart smb.service