安装samba软件
[root@localhost ~]#
yum install -y samba
设置samba开机自动启动
[root@localhost ~]# systemctl enable smb.service
启动samba
[root@localhost ~]#
systemctl start smb.service
将root帐号加入smbpasswd使该帐号可以通过samba服务访问
[root@localhost ~]# smbpasswd -a root
New SMB password:********** # 设置访问密码
Retype new SMB password:********** # 重复上面输入的访问密码
Added user root.
[root@localhost ~]# smbpasswd -e root
Enabled user root.
[root@localhost ~]#
smbpasswd参数说明:
-c:指定samba的配置文件
-a:向smbpasswd文件中添加指定的用户
-x:从smbpasswd文件中删除指定的用户
-d:在smbpasswd文件中禁用指定的用户
-e:在smbpasswd文件中激活指定的用户
-n:将指定的用户的密码置空
修改samba配置文件
[root@localhost ~]#
cp /etc/samba/smb.conf /etc/samba/smb.conf.default && cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@localhost ~]# vim /etc/samba/smb.conf
[global]
workgroup = WorkGroup
[CentOS 7 For Demo]
path = /
writeable = yes
public = yes
guest ok = yes
[root@localhost ~]#
放行445端口号
[root@localhost ~]#
firewall-cmd --zone=public --add-port=445/tcp --permanent
[root@localhost ~]# systemctl restart firewalld.service
关闭SELinux
[root@localhost ~]#
cp /etc/selinux/config /etc/selinux/config.default && cp /etc/selinux/config /etc/selinux/config.bak
[root@localhost ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost ~]# shutdown -r now # 修改SELinux需要重启服务器才能生效
在Windows系统下只要按下组合快捷键『Win+R』然后输入『\\192.168.***.***』即可通过samba服务访问CentOS系统里的文件。