linux ftp 服务器搭建教程(虚拟用户)

1. Install vsftpd:
    yum install vsftpd

2. Add a virtual user:
    useradd virtual_user -s /sbin/nologin
    mkdir /ftpboot
    chown virtual_user.virtual_user /ftpboot -R
    chmod 764 /ftpboot -R

3. Create username and password for virtual user:
    cd /etc/vsftpd/
    vi virtual_user

    the file looks like this:
    user1
    password1
    user2
    password2

4. Convert the  password file to a db format file:
    db_load -T -t hash -f /etc/vsftpd/virtual_user /etc/vsftpd/virtual_user.db

5. Config the PAM file(/etc/pam.d/vsftpd):
    add 2 line stuff like this(You must hide or delete others):
    auth    required        /lib/security/pam_userdb.so     db=/etc/vsftpd/virtual_user
    account required        /lib/security/pam_userdb.so     db=/etc/vsftpd/virtual_user

6. Create config file for virtual user:
    mkdir -p /etc/vsftpd/virtual_user_conf
    vi /etc/vsftpd/virtual_user_conf/user1

    the file looks like this:
    local_root=/ftpboot/
    write_enable=YES
    anon_upload_enable=YES
    anon_mkdir_write_enable=YES
    anon_world_readable_only=NO
    anon_other_write_enable=YES

7. Create the director for all users:
    mkdir -p /ftpboot/user1
    mkdir -p /ftpboot/user1/public

    mount --bind /ftpboot/public /ftpboot/user1/public
    mount -o remount,ro /ftpboot/user1/public

    chown virtual_user.virtual_user /ftpboot -R
    chmod 764 /ftpboot -R
    chmod 555 /ftpboot/public -R

8. Modify the vsftpd.conf file:
    anonymous_enable=NO
    pam_service_name=vsftpd
    tcp_wrappers=YES
    chroot_local_user=YES
    guest_enable=YES
    guest_username=virtual_user
    user_config_dir=/etc/vsftpd/virtual_user_conf

9. Check the selinux configure
    sestatus -b | grep ftp
    if it display like this:
    ftp_home_dir                                off
    then run this command to enable it:
    setsebool -P ftp_home_dir on
    or disable the selinux directly(change the /etc/selinux/config to disable it: SELINUX=disabled).

10. Restart the vsftpd server:
    service vsftpd restart
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值