Sambaサーバー

**************************************************
[root@falcon21 ~]# yum -y install samba



ユーザーをSambaサーバーアクセス用ユーザーとする
[root@falcon21 ~]# pdbedit -a hayato

新規ユーザー作成時にsamba用ディレクトリ作成
[root@falcon21 ~]# mkdir /etc/skel/samba

既存ユーザーsamba用ディレクトリ作成
[root@falcon21 ~]# vi mkhomedir.sh
#!/bin/bash

for user in `ls /home`
do

id $user > /dev/null 2>&1
[ $? -eq 0 ] && \
[ ! -d /home/$user/samba ] && \
mkdir /home/$user/samba && \
chown $user:$user /home/$user/samba && \
echo "/home/$user/samba create"

done

------------------------------
samba用ディレクトリ作成実行
[root@falcon21 ~]# sh mkhomedir.sh

-------------------------
共有ディレクトリ作成
[root@falcon21 ~]# mkdir /home/samba
[root@falcon21 ~]# chown nobody:nobody /home/samba

------------------------
Samba設定
[root@falcon21 ~]# vi /etc/samba/smb.conf
[global]
unix charset = UTF-8
dos charset = CP932
mangled names = no
vfs objects = catia
catia:mappings = 0x22:0xa8,0x2a:0xa4,0x2f:0xf8,0x3a:0xf7,0x3c:0xab,0x3e:0xbb,0x3f:0xbf,0x5c:0xff,0x7c:0xa6
hosts allow = 192.168.2. 127. 192.168.0.
workgroup = FALCON1
server string = Samba Server %v
netbios name = centos7
security = user
map to guest = bad user
dns proxy = no
#==========================================================
[public]
comment = Public Stuff
path = /home/samba
public = yes
writable = yes
only guest = yes
vfs objects = recycle
recycle:repository = .recycle
recycle:keeptree = no
recycle:versions = yes
recycle:touch = no
recycle:maxsize = 0
recycle:exclude = *.tmp ~$*
#[Share]
#path = /home/share/
#browsable =yes
##writable = yes
#guest ok = yes
#read only = no
[Share]
path = /
browsable =yes
writable = yes
guest ok = yes
read only = no

--------------------------
Samba起動
[root@falcon21 ~]# systemctl start smb
[root@falcon21 ~]# systemctl start nmb 

[root@falcon21 ~]# systemctl enable smb
[root@falcon21 ~]# systemctl enable smb

-----------------------------------------------------
ごみ箱内のファイルを自動的に削除
[root@falcon21 ~]# yum -y install tmpwatch

自動削除スクリプト作成
[root@falcon21 ~]# vi /etc/cron.weekly/recyclewatch
#!/bin/bash
for user in `ls /home/`
do

if [ -d /home/$user/.recycle ]; then
tmpwatch -f 720 /home/$user/.recycle/
fi

done

---------------
[root@falcon21 ~]# chmod +x /etc/cron.weekly/recyclewatch

------------------------------------
root@falcon21 ~]# systemctl reload smb

************************************************************************

投票数:2 平均点:10.00

 
Back to Top