samba伺服器設定(CentOS 7)
阿新 • • 發佈:2018-12-15
1 安裝samba
線上安裝命令:
[[email protected] ~]# yum install samba
安裝完成後查詢得到:
[[email protected] ~]# rpm -qa | grep samba samba-common-tools-4.2.10-7.el7_2.x86_64 samba-common-libs-4.2.10-7.el7_2.x86_64 samba-libs-4.2.10-7.el7_2.x86_64 samba-common-4.2.10-7.el7_2.noarch samba-client-libs-4.2.10-7.el7_2.x86_64 samba-4.2.10-7.el7_2.x86_64
#2 配置samba
root使用者安全驗證登入模版
修改/etc/samba/smb.conf
檔案
[[email protected] ~]# vi /etc/samba/smb.conf
[global]
security = user #只能用user
map to guest = bad user
共享目錄以及許可權,可以新增到最後
[data] path=/root/data browsable =yes writable = yes guest ok = yes valid user = root read only = no
更改共享資料夾讀寫許可權:
[[email protected] ~]# chmod –R 777 /root/data
重啟程序,開啟程序自啟動
[[email protected] ~]# systemctl enable smb.service [[email protected] ~]# systemctl enable nmb.service [[email protected] ~]# systemctl restart smb.service [[email protected] ~]# systemctl restart nmb.service
3 關閉selinux
[[email protected] ~]# vi /etc/selinux/config
將SELINUX=enforcing
改為SELINUX=disabled
, 重啟機器即可
直接執行命令:
[[email protected] ~]# setenforce 0
可以臨時關閉,重啟之後不在。
4 關閉防火牆
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[[email protected] ~]# firewall-cmd --state
not running
5 samba使用者管理
[[email protected] ~]# useradd root -d /root/data -s /bin/false #新增samba使用者
[[email protected] ~]# smbpasswd -a root#設定samba的登入密碼
6 開啟啟動項設定
開機預設關閉防火牆
[[email protected] ~]# chkconfig --level 345 firewalld off
開機預設啟動samba
[[email protected] ~]# chkconfig --level 345 smb on