EndSound's Life

【技術】Linux架設Samba

安裝samba

$ yum install samba samba-client samba-common cifs-utils

建立欲分享的目錄

$ mkdir /opt/share-folder

設定 /etc/samba/smb.conf,詳細的設定可以參考/etc/samba/smb.conf.exampe

$ vim /etc/samba/smb.conf

...
[share-folder]
        path =  /opt/share-folder
        valid users = root
        admin users = root
        write list = root
        guest ok = yes
        browseable = yes
        read only = no
        create  mask = 0664
        directory mask = 0755

建立上面設定的帳號

$ smbpasswd -a root

設定開機啟動

$ systemctl enable smb
$ systemctl enable nmb

使用指令查看port是否開啟

$ netstat -tnlp | grep 445

新增防火牆規則

$ firewall-cmd --permanent --zone=public --add-service=samba
$ firewall-cmd --reload

使用subclient測試

$ smbclient -L //127.0.0.1 -U root

掛載至本機其他資料夾

$ mount -t cifs -o username=root //127.0.0.1/share-folder /mnt/smb

參考:
Joseph’s Blog
鳥哥的Linux私房菜

發表迴響