N25-第13周博客作业

1、建立samba共享,共享目录为/data,要求:(描述完整的过程)
  1)共享名为shared,工作组为magedu;
  2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名;
  3)添加samba用户gentoo,centos和ubuntu,密码均为“magedu”;
  4)此samba共享shared仅允许develop组具有写权限,其他用户只能以只读方式访问;
  5)此samba共享服务仅允许来自于10.0.0.0/16网络的主机访问; 
  
2、搭建一套文件vsftp文件共享服务,共享目录为/ftproot,要求:(描述完整的过程)
  1)基于虚拟用户的访问形式;
  2)匿名用户只允许下载,不允许上传;
  3)禁锢所有的用户于其家目录当中;
  4)限制最大并发连接数为200:;
  5)匿名用户的最大传输速率512KB/s
  6)虚拟用户的账号存储在mysql数据库当中。
  7)数据库通过NFS进行共享。
  
题目1:
1.安装samba
    [root@rs1 ~]# yum -y install samba
    
2.添加组,用户以及创建共享目录
    [root@rs1 ~]# groupadd develop
    [root@rs1 ~]# useradd -G develop gentoo
    [root@rs1 ~]# useradd -G develop centos
    [root@rs1 ~]# for user in {gentoo,centos,ubuntu};do echo $user;done
    [root@rs1 ~]# mkdir /data
    
3.修改共享目录权限
    [root@rs1 ~]# chmod g+w /data
    
4.编辑samba配置文件:
    /etc/samba/smb.conf,添加如下配置:
        [shared]
        comment = week test
        path = /data
        browseable = yes
        public = no
        write = yes
        write list = +develop
        hosts allow = 10.0.0.0/255.255.0.0
        
5.启动服务:
    [root@rs1 ~]# systemctl start smb.service 
    查看是否启用端口445,139
    
6.测试:
    [root@rs2 ~]# smbclient -L 10.0.0.21 -U ubuntu
    Enter gentoo's password: 
    Domain=[MAGEDU] OS=[Windows 6.1] Server=[Samba 4.2.10]
    Sharename       Type      Comment
    ---------       ----      -------
    shared          Disk      week test
    IPC$            IPC       IPC Service (Samba Server Version 4.2.10)
    Domain=[MAGEDU] OS=[Windows 6.1] Server=[Samba 4.2.10]
    Server               Comment
    ---------            -------
    RS1                  Samba Server Version 4.2.10
    Workgroup            Master
    ---------            -------
    MAGEDU               RS1
    
    [root@rs2 ~]# mount -t cifs //10.0.0.21/shared /mnt -o username=ubuntu -o password=magedu
    mount: //10.0.0.21/shared is write-protected, mounting read-only
    mount: cannot mount //10.0.0.21/shared read-only
    [root@rs2 ~]# mount -t cifs //10.0.0.21/shared /mnt -o username=gentoo -o password=magedu
    [root@rs2 ~]# df -hT|grep mnt
    //10.0.0.21/shared           cifs       18G  2.3G   16G  13% /mnt
    [root@rs2 ~]# cd /mnt
    [root@rs2 mnt]# touch test1
    [root@rs2 mnt]# ll
    total 0
    -rw-r--r-- 1 1003 1006 0 Nov 11 23:01 test1
    [root@rs1 ~]# id gentoo
    uid=1003(gentoo) gid=1006(gentoo) groups=1006(gentoo),1005(develop)
    
题目2:
    环境:
        rs2:mysql+vsftpd
        rs1:smaba

    1.安装MySQL
        [root@rs2 ~]# groupadd -g 1100 mysql
        [root@rs2 ~]# useradd -u 1100 -g mysql -M mysql
        [root@rs2 ~]# mount -t cifs //10.0.0.21/mysql /opt/mysql -o username=mysql -o password=magedu
        [root@rs2 ~]# chown -R mysql.mysql /opt/mysql
        
        [root@rs2 ~]# tar xf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
        [root@rs2 ~]# cd /usr/local
        [root@rs2 local]# ln -sv mysql-5.6.31-linux-glibc2.5-x86_64 mysql
        [root@rs2 local]# cd mysql
        [root@rs2 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/opt/mysql
        [root@rs2 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
        [root@rs2 mysql]# chmod +x /etc/init.d/mysqld
        [root@rs2 mysql]# cp support-files/my-default.cnf /etc/my.cnf
        
        [root@rs2 mysql]# vim /etc/my.cnf
            basedir = /usr/local/mysql
            datadir = /opt/mysql
            skip_name_resolve = 1
            character_set_server = utf8
            innodb_file_per_table = 1
            
        [root@rs2 mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
        [root@rs2 mysql]# vim /etc/ld.so.conf.d/mysql.conf
            /usr/local/mysql/lib
        
        [root@rs2 mysql]# ldconfig -v
        [root@rs2 mysql]# vim /etc/profile.d/mysql.sh
            export PATH=/usr/local/mysql/bin:$PATH
        [root@rs2 mysql]# source /etc/profile.d/mysql.sh
        [root@rs2 mysql]# service mysqld start
        
2.安装vsftpd
    [root@rs2 ~]# yum -y install vsftpd pam-devel
    
    安装pam_mysql:
    [root@rs2 ~]# tar xf pam_mysql-0.7RC1.tar.gz 
    [root@rs2 ~]# cd pam_mysql-0.7RC1
    [root@rs2 pam_mysql-0.7RC1]# ./configure --with-mysql=/usr/local/mysql/ --with-pam-mods-dir=/lib64/security/
    [root@rs2 pam_mysql-0.7RC1]# make install
      编辑vsftpd.conf配置文件:
        anonymous_enable=YES
        anon_upload_enable=NO
        anon_mkdir_write_enable=NO
        anon_max_rate=512000
        max_clients=200
        local_enable=YES
        write_enable=YES
        local_umask=022
        dirmessage_enable=YES
        xferlog_enable=YES
        connect_from_port_20=YES
        xferlog_file=/var/log/xferlog
        xferlog_std_format=YES
        download_enable=YES
        ascii_upload_enable=YES
        ascii_download_enable=YES
        chroot_local_user=YES
        listen=YES
        listen_ipv6=NO
        guest_enable=YES
        guest_username=mysqlftp
        virtual_use_local_privs=YES
        pam_service_name=vsftpd
        tcp_wrappers=YES
        vsftpd_log_file=/var/log/vsftpd.log
        allow_writeable_chroot=YES
        
    创建虚拟用户映射账户:
        [root@rs2 ~]# useradd mysqlftp -d /ftproot
        
    编辑vsftpd的pam认证文件:/etc/pam.d/vsftpd
        #%PAM-1.0
        session    optional     pam_keyinit.so    force revoke
        auth       sufficient   /lib64/security/pam_mysql.so user=vsftp passwd=redhat \
        host=127.0.0.1 db=ftp table=users usercolumn=name passwdcolumn=password crypt=2
        auth       requiredpam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
        auth       requiredpam_shells.so
        auth       includepassword-auth
        account    sufficient   /lib64/security/pam_mysql.so user=vsftp passwd=redhat \
        host=127.0.0.1 db=ftp table=users usercolumn=name passwdcolumn=password crypt=2
        account    includepassword-auth
        session    required     pam_loginuid.so
        session    includepassword-auth
        
    备注:此认证文件可以使vsftpd服务应用虚拟账号和本地账号;如果只想使用虚拟账号机制,
    则只使用pam_mysql相关的2行;此文件认证机制顺序:先检查pam_mysql认证机制;后检查本地账号密码认证机制;
    
    创建vsftpd使用的数据库:
        mysql> create database ftp;
        mysql> use ftp;
        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)
        );
        mysql> grant SELECT on ftp.* to vsftp@localhost identified by 'redhat';
        mysql> grant SELECT on ftp.* to [email protected] identified by 'redhat';
        添加一个虚拟账号:
        mysql> insert into users(name,password) values('nginx',password('redhat'));
        
    启动服务:
        [root@rs2 ~]# systemctl start vsftpd
        
3.测试
    [root@rs1 ~]# lftp -u nginx,redhat 10.0.0.22
    lftp [email protected]:~> ls
    -rw-r--r--    1 0        0            1667 Nov 12 08:58 passwd
    lftp [email protected]:/> exit
    [root@rs1 ~]# lftp 10.0.0.22
    lftp 10.0.0.22:~> ls
    drwxr-xr-x    2 0        0               6 Mar 31  2016 pub
    lftp 10.0.0.22:/> quit
    [root@rs1 ~]# lftp -u devon,redhat 10.0.0.22
    lftp [email protected]:~> ls
    -rw-r--r--    1 0        0            1667 Nov 12 08:58 passwd
    lftp [email protected]:/> quit
    [root@rs1 ~]# lftp -u nginx,redhat 10.0.0.22
    lftp [email protected]:~> ls
    -rw-r--r--    1 0        0            1667 Nov 12 08:58 passwd
    lftp [email protected]:/> quit

原创文章,作者:oranix,如若转载,请注明出处:http://www.178linux.com/76616

(0)
oranixoranix
上一篇 2017-05-21 20:39
下一篇 2017-05-21 20:44

相关推荐

  • N25-第三周作业

    1.列出当前系统所有已经登录的用户的用户名,注意同一个用户登录多次,只显示一次即可   who | cut -d" " -f1 |uniq 2.取出最后登录到当前系统的用户的相关信息    w | tail -1 3.取出当前系统上被用户当做其默认shell最多的那个shell &nbsp…

    Linux干货 2016-12-19
  • Linux三剑客之grep

    grep(Globel Search Regular Expression and Printing out the line)全面搜索正则表达式并把行打印出来)是一个强大的文本搜索工具,使用正则表达式搜索文本的文本,并把结果打印出来。Unix家族包括grep、egrep和fgrep。egrep是扩张的正则表达式它支持更多的字符,fgrep是fast gre…

    Linux干货 2016-08-12
  • 进程管理工具

    进程管理工具 kill man 7 signal 1) SIGHUP: 无须关闭进程而让其重读配置文件 kill -1 进程编号 2) SIGINT: 中止正在运行的进程;相当于Ctrl+c 9) SIGKILL: 杀死正在运行的进程 再生进程 kill -9 杀不掉 15) SIGTERM:终止正在运行的进程 kill -15/或不写(默认) +进程编号。…

    Linux干货 2016-09-11
  • 马哥教育网络班22期+第5周课程练习

    1、显示当前系统上root、fedora或user1用户的默认shell; [root@localhost ~]# awk -F: '{print $1,$7}' /etc/passwd| egrep "^\<(root|fedora|user…

    Linux干货 2016-09-15
  • Linux 系统启动流程与grub的应用

    一 Linux 系统启动流程    POST –> BIOS(Boot Sequence) –> MBR(bootloader) –> kernel + initramfs(或initrd) –> rootfs (ro) –> /sbin/init …

    Linux干货 2016-03-07
  • test2

    欢迎使用马克飞象 作业帮 示例笔记本 马克飞象 帮助 Markdown 马克飞象是一款专为印象笔记(Evernote)打造的Markdown编辑器,通过精心的设计与技术实现,配合印象笔记强大的存储和同步功能,带来前所未有的书写体验。特点概述: 功能丰富 :支持高亮代码块、LaTeX 公式、流程图,本地图片以及…

    Linux干货 2017-03-20