nfsサーバーでもいいんですが、windowsユーザーが家にいるのでsambaにします。
[root@cent ~]$ yum -y install samba
[root@cent ~]$ mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
[root@cent ~]$ mv /etc/samba/smb.conf.example /etc/samba/smb.conf
[root@cent ~]$ emacs /etc/samba/smb.conf
変更と追記する内容
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos
hosts allow = [アクセス制限許可するIP範囲]
security = user
dns proxy = no
map to guest = bad user
[Public]
comment = Public Share
path = /home/samba/share/
browsable = yes
writable = yes
guest ok = yes
read only = no
[root@cent ~]$ mkdir -p /home/samba/share
[root@cent ~]$ chmod -R 777 /home/samba/share
[root@cent ~]$ chmod -R 777 /home/samba/
[root@cent ~]$ chown -R nobody:nobody /home/samba/share
Loaded services file OK.
ならOK
[root@cent ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[Public]"
Loaded services file OK.
Server role: ROLE_STANDALONE
サービスの有効化
[root@cent ~]# systemctl enable smb.service
[root@cent ~]# systemctl enable nmb.service
サービスの起動
[root@cent ~]# systemctl start smb.service
[root@cent ~]# systemctl start nmb.service
[root@cent ~]# firewall-cmd --permanent --zone=public --add-service=samba
success
[root@cent ~]# firewall-cmd --reload
success
[root@cent ~]# chcon -R -t samba_share_t /home/samba/share
Windowsなら
\\[IPアドレス]
Linuxからは
smb://[IPアドレス]/
guestでアクセスするのではなくて、特定のユーザーごとに接続の認証をするときには以下を追加する
[root@cent ~]# useradd samba
[root@cent ~]# groupadd smb
[root@cent ~]# usermod -a smb samba
[root@cent ~]# pdbedit -a samba
new password:
retype new password:
[root@cent ~]# mkdir /home/samba/Data
[root@cent ~]# chown -R samba:smb /home/samba/Data/
[root@cent ~]# chmod -R 777 /home/samba/Data/
[root@cent ~]# chcon -R -t samba_share_t /home/samba/Data
[root@cent ~]$ emacs /etc/samba/smb.conf
追記する内容
[Data]
comment = Data Share
path = /home/samba/Data/
valid users = @smb
browsable = yes
writable = yes
guest ok = no
read only = no
Loaded services file OK.
ならOK
[root@cent ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[Public]"
Processing section "[Data]"
Loaded services file OK.
Server role: ROLE_STANDALONE
[root@cent ~]# systemctl restart smb.service
[root@cent ~]# systemctl restart nmb.service