• Centos7搭建给予虚拟用户的FTP服务


    在这里插入图片描述
    1.安装vsftpd服务

    yum -y install vsftpd
    
    • 1

    2.配置虚拟用户
    2.1)创建虚拟账号数据库文件

    [root@node1 vsftpd]# cat /etc/vsftpd/vusers.list
    bob
    pwd@123
    tom
    pwd@123
    [root@node1 vsftpd]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    2.2)生成虚拟账户数据库文件

    [root@node1 vsftpd]# db_load -T -t hash -f /etc/vsftpd/vusers.list /etc/vsftpd/vusers.db
    
    • 1

    2.3)添加虚拟账户映射创建FTP根目录

    [root@node1 vsftpd]# mkdir -p /mnt/mfs/ftp
    [root@node1 vsftpd]# useradd -d /mnt/mfs/ftp/ -s /sbin/nologin virtua
    
    • 1
    • 2

    2.4)设置FTP根目录的权限

    [root@node1 vsftpd]# chmod 755 /mnt/mfs/ftp/
    
    • 1

    3.配置PAM身份验证和创建虚拟账户权限目录
    3.1)配置PAM验证

    [root@node1 vsftpd]# vim /etc/pam.d/vsftpd.vu
    #%PAM-1.0
    auth    required        pam_userdb.so db=/etc/vsftpd/vusers
    account required        pam_userdb.so db=/etc/vsftpd/vusers
    
    • 1
    • 2
    • 3
    • 4

    3.2 创建虚拟账户权限目录

    [root@node1 vsftpd]# mkdir /etc/vsftpd/vusers_dir
    
    • 1

    4.修改VSFTP主配置文件配置虚拟账户FTP
    4.1)修改vsftpd.conf配置文件

    [root@node1 vsftpd]# cat /etc/vsftpd/vsftpd.conf
    anonymous_enable=NO
    local_enable=YES
    write_enable=YES
    local_umask=022
    anon_umask=022
    dirmessage_enable=YES
    xferlog_enable=YES
    connect_from_port_20=YES
    xferlog_std_format=YES
    listen=NO
    listen_ipv6=YES
    chroot_local_user=YES
    allow_writeable_chroot=YES
    guest_enable=YES
    guest_username=virtual
    user_config_dir=/etc/vsftpd/vusers_dir/
    pam_service_name=vsftpd.vu
    userlist_enable=YES
    tcp_wrappers=YES
    [root@node1 vsftpd]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    4.2)创建虚拟账户权限文件

    [root@node1 vsftpd]# touch /etc/vsftpd/vusers_dir/bob
    [root@node1 vsftpd]# touch /etc/vsftpd/vusers_dir/tom
    
    • 1
    • 2

    4.3)权限划分给bob用户设置访问FTP完全控制权限

    [root@node1 vsftpd]# cat /etc/vsftpd/vusers_dir/bob
    anon_upload_enable=YES
    anon_mkdir_write_enable=YES
    anon_other_write_enable=YES
    [root@node1 vsftpd]#
    
    • 1
    • 2
    • 3
    • 4
    • 5

    4.4)权限划分给tom用户设置只有上传权限

    [root@node1 vsftpd]# cat /etc/vsftpd/vusers_dir/tom
    anon_upload_enable=YES #改成NO权限变为只能下载
    [root@node1 vsftpd]#
    
    • 1
    • 2
    • 3

    4.5)修改FTP根目录的所有者

    [root@node1 vsftpd]# chown virtual:virtual /mnt/mfs/ftp/
    
    • 1

    4.6)启动FTP服务

    [root@node1 vsftpd]# systemctl restart vsftpd
    
    • 1

    ps:遇到的问题 user_list

    解决方法:touch /etc/vsftpd/user_list
    
    • 1

    FileZilla连接FTP提示:不安全的服务器,不支持 FTP over TLS
    1.检查vsftpd师范支持ssl模块

    [root@node1 vusers_dir]# ldd $(which vsftpd)|grep ssl
            libssl.so.10 => /lib64/libssl.so.10 (0x00007f1d5e682000)
    
    • 1
    • 2

    2.生成ssl证书

    [root@node1 vusers_dir]# openssl req -new -x509 -nodes -out vsftpd.pem -keyout vsftpd.pem
    
    • 1

    证书配置解析:

    Generating a 2048 bit RSA private key
    .............................................................+++
    ..........................................................................+++
    writing new private key to 'vsftpd.pem'
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [XX]:CN  #国家名称(2个字母代码)[XX]:CN
    State or Province Name (full name) []:CHINA   #国家或省名(全称)[]:中国
    Locality Name (eg, city) [Default City]:CHINA #地名(如城市)[默认城市]:中国
    Organization Name (eg, company) [Default Company Ltd]:ORG #组织名称(如公司)[默认公司有限公司]:ORG
    Organizational Unit Name (eg, section) []:ORG   #组织单元名称(例如,节)[]:ORG
    Common Name (eg, your name or your server's hostname) []:   #常用名称(例如,您的名称或服务器的主机名)[]:Name
    Email Address []:  #电子邮件地址[]:EMAIL@163.com
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    移动证书文件

    [root@node1 vusers_dir]# mv vsftpd.pem /etc/ssl/certs/
    [root@node1 vusers_dir]# chmod 400 /etc/ssl/certs/vsftpd.pem
    
    • 1
    • 2

    3.修改vsftpd.conf配置文件
    在最后面天添加下列配置

    ssl_enable=YES
    allow_anon_ssl=NO
    force_local_data_ssl=YES
    force_local_logins_ssl=YES
    force_anon_logins_ssl=YES
    force_anon_data_ssl=YES
    ssl_tlsv1=YES
    ssl_sslv2=NO
    ssl_sslv3=NO
    require_ssl_reuse=NO
    ssl_ciphers=HIGH
    rsa_cert_file=/etc/ssl/certs/vsftpd.pem
    rsa_private_key_file=/etc/ssl/certs/vsftpd.pem
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    4.重启vsftpd服务

    [root@node1 vsftpd]# systemctl restart vsftpd
    
    • 1
  • 相关阅读:
    pg数据库加密和解密,对应java的加密和解密
    P3743 kotori的设备
    Qt开发经验小技巧241-245
    【Linux】 进程信号的发生
    yarn的安装及使用
    AndroidStudio 编译输出中文乱码
    阿里云ACP知识点(三)
    STM32使用ThreadX示例以及tx_thread_create解析
    IvorySQL3.0:基于PG16.0最新内核,实现兼容Oracle数据库再升级
    HTML网页设计——轮滑运动体育类人物介绍主题12页面毕业设计网页
  • 原文地址:https://blog.csdn.net/weixin_43822878/article/details/125633480