server0首先裝軟件
yum install samba samba-client -y
vim /etc/samba/smb.conf
在文件末尾添加配置
[share] #共享目錄名稱
path = /public #共享目錄路徑
browseable = yes #允許訪問
添加samba用戶
smbpasswd - a testuser
開啟防火牆和selinux權限后,客戶端即可訪問共享目錄。
desktop0安裝samba客戶端后,測試:
smbclient -L server0 #查看server0上的smb共享目錄,然后掛在遠程目錄到本地即可使用
yum -y install cifs-utils #首先安裝文件系統cifs
mount //server0.example.com -o username=testuser,password=redhat /mnt #手動掛載遠程目錄到本地。
安裝autofs實現自動掛載:
yum -y install autofs
vim /etc/auto.master #編輯配置文件,指定自動掛載二級配置文件路徑
/- /etc/auto.share #主配置文件末尾添加一行,指定使用絕對路徑、新配置文件是/etc/auto.share
cp /etc/auto.misc /etc/auto.share #復制一份配置文件模板並編輯
vim /etc/auto.share #添加如下內容
/mnt/share -fstype=cifs,username=testuser,password=redhat ://server0.example.com/share
systemctl enable autofs
systemctl restart autofs