1、建立samba共享,共享目录为/data,要求:(描述完整的过程) 1)共享名为shared,工作组为magedu; 2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名; 3)添加samba用户gentoo,centos和ubuntu,密码均为“mageedu”; 4)此samba共享shared仅允许develop组具有写权限,其他用户只能以只读方式访问; 5)此samba共享服务仅允许来自于172.16.0.0/16网络的主机访问; [root@node3 samba]# yum -y install samba samba-client samba-common //安装samba [root@node3 samba]# vim /etc/samba/smb.conf //编辑配置文件设置samba目录 [global] workgroup = MYGROUP server string = Samba Server Version %v netbios name = MYSERVER ; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 hosts allow = 172.16.0.0/16 security = user //user,share,domain passdb backend = tdbsam [shared] comment = test path = /data //真实路径 browseable = yes writeable = no valid users = gentoo,centos,ubuntu,@develop write list = @develop read list = ubuntu [root@node3 ~]# mkdir /data [root@node3 ~]# service smb start [root@node3 ~]# smbclient -L //127.0.0.1 Enter root's password: //直接按enter Anonymous login successful Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-36.el6_8] Sharename Type Comment --------- ---- ------- shared Disk test [root@node3 ~]# groupadd develop //添加samba路径和组 [root@node3 ~]# useradd -G develop gentoo [root@node3 ~]# echo "gentoo" | passwd --stdin gentoo [root@node3 ~]# useradd -G develop centos [root@node3 ~]# echo "centos" | passwd --stdin centos [root@node3 ~]# useradd ubuntu [root@node3 ~]# echo "ubuntu" | passwd --stdin centos [root@node3 ~]# smbpasswd -a gentoo New SMB password: Retype new SMB password: Added user gentoo. [root@node3 ~]# smbpasswd -a centos New SMB password: Retype new SMB password: Added user centos. [root@node3 ~]# smbpasswd -a ubuntu New SMB password: Retype new SMB password: Added user ubuntu. [root@node3 ~]# service nmb start [root@node3 ~]# service smb start [root@node3 ~]# smbclient -L //127.0.0.1/data -U centos //使用centos账户登陆samba Enter centos's password: Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-36.el6_8] Sharename Type Comment --------- ---- ------- IPC$ IPC IPC Service (Samba Server Version 3.6.23-36.el6_8) shared Disk test centos Disk Home Directories [root@node3 ~]# mount -t cifs //127.0.0.1/centos /mnt -o username=centos Password: [root@node3 ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 20106900 2620240 16458616 14% / tmpfs 510008 0 510008 0% /dev/shm /dev/sda1 194241 149019 34982 81% /boot //127.0.0.1/centos 20106900 2620240 16458616 14% /mnt 2、搭建一套文件vsftp文件共享服务,共享目录为/ftproot,要求:(描述完整的过程) 1)基于虚拟用户的访问形式; 2)匿名用户只允许下载,不允许上传; 3)禁锢所有的用户于其家目录当中; 4)限制最大并发连接数为200:; 5)匿名用户的最大传输速率512KB/s 6)虚拟用户的账号存储在mysql数据库当中。 7)数据库通过NFS进行共享。 [root@node3 ~]# yum -y install vsftp mysql-server mysql-devel pam_mysql [root@node3 ~]# vim /etc/exports //为共享数据库提供共享文件系统 /data 192.168.1.116 [root@node3 ~]# service nfs start //启动nfs 启动 NFS 服务: exportfs: No options for /data 192.168.1.116: suggest 192.168.1.116(sync) to avoid warning [确定] 关掉 NFS 配额: [确定] 启动 NFS mountd: [确定] 启动 NFS 守护进程: [确定] 正在启动 RPC idmapd: [确定] [root@node3 ~]# mount -t nfs 192.168.1.116:/data /mnt [root@node3 ~]# vim /etc/my.cnf //修改数据库存储位置 [mysqld] datadir=/data socket=/var/lib/mysql/mysql.sock user=mysql 创建虚拟账户用户 [root@node3 ~]# service mysqld start [root@node3 ~]# mysql mysql> create database vsftp; Query OK, 1 row affected (0.13 sec) mysql> use vsftp Database changed mysql> grant select on vsftp.* to vsftp@'192.168.1.%' identified by 'www.magedu.com'; Query OK, 0 rows affected (0.00 sec) mysql> create table users ( id int AUTO_INCREMENT NOT NULL, name char(20) binary NOT NULL, password char(48) binary NOT NULL, primary key(id) ); Query OK, 0 rows affected (0.12 sec) mysql> insert into users(name,password) values('magedu',password('magedu')); Query OK, 1 row affected (0.00 sec) pam认证 [root@node3 ~]# vim /etc/pam.d/vsftpd.mysql auth required /lib/security/pam_mysql.so user=vsftpd passwd=www.magedu.com host=localhost db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2 account required /lib/security/pam_mysql.so user=vsftpd passwd=www.magedu.com host=localhost db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2 [root@node3 ~]# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.confbak [root@node3 ~]# vim /etc/vsftpd/vsftpd.conf anonymous_enable=YES local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_std_format=YES chroot_local_user=YES chroot_list_enable=YES chroot_list_file=/etc/vsftpd/chroot_list listen=YES pam_service_name=vsftpd.mysql userlist_enable=YES tcp_wrappers=YES max_clients=200 anon_max_rate=512 [root@node3 ~]# service vsftpd start [root@node3 ~]# ftp 192.168.1.116 Connected to 192.168.1.116 (192.168.1.116). 220 (vsFTPd 2.2.2) Name (192.168.1.116:root): magedu 331 Please specify the password. Password: 530 Login incorrect. Login failed. ftp> 以上
原创文章,作者:N21_619463772,如若转载,请注明出处:http://www.178linux.com/57245