• linux安装vsftp


    安装vsftpd

    yum -y install vsftpd
    
    • 1

    创建ftp用户

    -d表示将新建用户的家目录设置为/www/wwwroot/tp
    -s /sbin/nologin 表示不允许用户登录linux系统只能通过ftp连接

    useradd -d /www/wwwroot/tp -s /sbin/nologin ftp
    
    • 1

    给用户设置密码
    输入 passwd ftp之后按下回车设置密码即可

    passwd ftp
    
    • 1

    查看/etc/shells文件,如果没有/sbin/nologin这一项就在末行追加,否则会报错530

    vim /etc/shells
    
    • 1

    如果文件中没有/sbin/nologin则添加在最后一行即可

    修改vsftpd.conf配置文件

    //不允许匿名用户登录
    anonymous_enable=NO
    //只允许本地用户登录
    local_enable=YES
    //允许ftp用户写操作
    write_enable=YES
    //限制ftp用户登录后只能在家目录活动,不可以跳转上一级目录
    chroot_local_user=YES
    //开启list_file文件的开关,设置为YES的时候表示chroot_list文件中的用户可以任意跳转目录
    chroot_list_enable=YES
    chroot_list_file=/etc/vsftpd/chroot_list
    //开启白名单,只允许userlist_file文件中的用户登录ftp
    userlist_enable=YES
    userlist_deny=no
    userlist_file=/etc/vsftpd/allowed_users
    seccomp_sandbox=no
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    创建限制文件

    touch /etc/vsftpd/chroot_list
    
    • 1

    创建白名单文件

    touch /etc/vsftpd/allowed_users
    
    • 1

    编辑白名单文件将新添加ftp用户添加到文件中

    vim /etc/vsftpd/allowed_users
    
    • 1

    在文件中添加ftp,每一行代表一个用户

    修改后重启vsftpd服务

    systemctl restart vsftpd
    
    • 1

    下载ftp服务,以检测我们的ftp用户能否正常登录

    yum install ftp
    
    • 1

    登录本地的ftp用户

    ftp 127.0.0.1
    
    • 1

    在提示中输入用户名再按下回车键输入密码,显示

    230 Login successful.
    则代表登录成功

    [root@VM-8-9-centos wwwroot]# ftp 127.0.0.1
    Connected to 127.0.0.1 (127.0.0.1).
    220 (vsFTPd 3.0.2)
    Name (127.0.0.1:root): ftp
    331 Please specify the password.
    Password:
    230 Login successful.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp> 
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    如果需要退出只需要输入exit命令即可

    ftp> exit
    221 Goodbye.
    [root@VM-8-9-centos wwwroot]# 
    
    
    • 1
    • 2
    • 3
    • 4
  • 相关阅读:
    产品经理-战略-战略的含义和层级
    聊聊Vim的工作原理
    SAP月结在制品结算时不产生凭证的一个问题
    为了方便,采用数据库连接池druid
    【web开发】11、文件的上传
    mysql 常见操作指令
    评价指标(一)精确率,召回率,F1-score
    将文件移动到ubuntu/linux/centos虚拟机上
    【LeetCode】16.最接近的三数之和
    spring boot + mybaties-plus 数据库字段加解密
  • 原文地址:https://blog.csdn.net/qq_40787608/article/details/125613748