centos 安裝samba

關(guān)閉SELinux

# 臨時關(guān)閉
setenforce 0

# 修改配置文件

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
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

安裝samba

yum install samba samba-client samba-swat

安裝成功之后查看服務(wù)狀態(tài)

service smb status

# 以下是狀態(tài) 未啟動 證明安裝成功
  smb.service - Samba SMB Daemon
   Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

添加開機(jī)啟動

chkconfig  --level 35 smb on

取消開機(jī)啟動

chkconfig  --level 35 smb off

配置

添加 share 并指定目錄 /home/share

vim /etc/samba/smb.conf

# 修改為如下內(nèi)容
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
        workgroup = SAMBA
        security = user


        passdb backend = tdbsam

       # map to guest = Bad Password

        #guest account = guest

[share]
       comment = share folder
       path = /home/share
       create mask = 0664
       directory mask = 0775
       browseable = yes
       writable = yes
       public = yes

運(yùn)行 testparm 檢查配置是否正確

testparm

添加用戶

運(yùn)行下面命令 添加root用戶并設(shè)置密碼

smbpasswd -a root

啟動并查看狀態(tài)

service smb start
service smb status

客戶端安裝并映射

1. 安裝映射工具

 yum install cifs-utils

2. mount映射

mount -t cifs //serviceip//share /home/share -o username=root,password=123123

3. 取消映射

umount /home/share

4. 添加開機(jī)自動映射

vim /etc/fstab

#追加
//serviceip/share    /home/share             cifs    defaults,auto,username=root,password=123123 0 0
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容