The requirements for this script instance are as follows:
1. The company has public share directory, all employees can read and write, but do not allow the deletion of other employee's files; cannot log on anonymously
2, each department has a shared directory, department managers can read and write, department staff can read;
Non-departmental staff can not access (Caiwu, Renshi, Yewu, Kaifa, Kefu Department, each department has a number of employees)
3, all employees have a personal directory, other people can not access
4, to meet the different staff access habits, the above access requirements through FTP and samba can be the same access
5, the request uses the script realization
A, the installation configuration is completed automatically
B, automatically complete access settings when adding users
"Directory Planning":
/data/public
Caiwu (store user host directory)
Renshi)
Yewu
Kaifa
Kefu
Caiwu-pub (Departmental public directory)
Rensh-pub
Yewu-pub
Kaifa-pub
Kefu-pub
Directory Permissions: 750 owner: Department manager; Group: Department
User host Directory Sample:
/data/caiwu/cw1
Cw2
Cw3
"Add user command Example":
Useradd-g caiwu-d/DATA/CAIWU/CW1 CW1
"FTP User Access root directory":
Local_root=/data
"FTP Turn off Anonymous access":
Anonymous_enable=yes (change to No)
"Samba profile Add sharing example":
[Public]
Path=/data/public
Public=yes
Writable=yes
[Caiwu-pub]
Path=/data/caiwu-pub
Valid users= @caiwu
Write LIST=CW-JL
"Ftp-samba-install script follows":
#!/bin/bash
Yum-y Install VSFTPD samba*
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/Ftp/
Sed-i "s/anonymous_enable=yes/anonymous_enable=no/"/etc/vsftpd/vsftpd.conf
echo "Local_root=/data" >>/etc/vsftpd/vsftpd.conf
Mkdir-p/data/public
Mkdir-p/data/caiwu
Mkdir-p/data/renshi
Mkdir-p/data/yewu
Mkdir-p/data/kaifa
Mkdir-p/data/kefu
Mkdir-p/data/caiwu-pub
Mkdir-p/data/renshi-pub
Mkdir-p/data/yewu-pub
Mkdir-p/data/kaifa-pub
Mkdir-p/data/kefu-pub
Groupadd Caiwu
Groupadd Renshi
Groupadd Yewu
Groupadd Kaifa
Groupadd Kefu
Useradd-g caiwu-d/DATA/CAIWU/CW-JL CW-JL
Useradd-g renshi-d/DATA/RENSHI/RS-JL RS-JL
Useradd-g yewu-d/DATA/YEWU/YW-JL YW-JL
Useradd-g kaifa-d/DATA/KAIFA/KF-JL KF-JL
Useradd-g kefu-d/DATA/KEFU/KEFU-JL KEFU-JL
Chown cw-jl:caiwu/data/caiwu-pub
chmod 750/data/caiwu-pub
Chown rs-jl:renshi/data/renshi-pub
chmod 750/data/renshi-pub
Chown yw-jl:yewu/data/yewu-pub
chmod 750/data/yewu-pub
Chown kf-jl:kaifa/data/kaifa-pub
chmod 750/data/kaifa-pub
Chown kefu-jl:kefu/data/kefu-pub
chmod 750/data/kefu-pub
Chown Cw-jl:caiwu/data/caiwu
chmod 750/data/caiwu
Chown Rs-jl:renshi/data/renshi
chmod 750/data/renshi
Chown Yw-jl:yewu/data/yewu
chmod 750/data/yewu
Chown Kf-jl:kaifa/data/kaifa
chmod 750/data/kaifa
Chown Kefu-jl:kefu/data/kefu
chmod 750/data/kefu
chmod 1777/data/public
echo "Cw-jl:123" | CHPASSWD &>/dev/null
echo "Rs-jl:123" | CHPASSWD &>/dev/null
echo "Yw-jl:123" | CHPASSWD &>/dev/null
echo "Kf-jl:123" | CHPASSWD &>/dev/null
echo "Kefu-jl:123" | CHPASSWD &>/dev/null
echo "
[Public]
Path=/data/public
Public=yes
Writable=yes
[Caiwu-pub]
Path=/data/caiwu-pub
Valid users= @caiwu
Write LIST=CW-JL
[Renshi-pub]
Path=/data/renshi-pub
Valid users= @renshi
Write LIST=RS-JL
[Yewu-pub]
Path=/data/yewu-pub
Valid users= @yewu
Write LIST=YW-JL
[Kaifa-pub]
Path=/data/kaifa-pub
Valid users= @kaifa
Write LIST=KF-JL
[Kefu-pub]
Path=/data/kefu-pub
Valid users= @kefu
Write LIST=KEFU-JL
">>/etc/samba/smb.conf
Service VSFTPD Start
Service SMB Start
"Ftp-samba-useradd script follows":
#!/bin/bash
Read-p "Please input username:" Username
Read-p "Please input bumen:" Bumen
Useradd-g $bumen-D/data/$bumen/$username $username
passwd $username
Pdbedit-a $username
This article is from the "Soldier" blog, please be sure to keep this source http://ganbing.blog.51cto.com/7002794/1242838