linux6中ftp安装及用户创建

一:安装ftp

1.首先先安装ftp,使用yum命令

[root@localhost /]# yum install vsftpd
2.修改/etc/vsftpd/vsftpd.conf

[root@localhost /]# vi /etc/vsftpd/vsftpd.conf 

3.关闭匿名用户登录

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
4.限制用户只能访问跟路径(默认/home/test)

# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
将chroot_list的两个注释解开,并且在/etc/vsftpd下创建chroot_root文件,在文件中添加你要限制的用户,一个用户一行,切记。

5.开启监听,曾在linux7中尝试,却始终无法启动,后使用linux6.4一次就成功了,不知道为什么。。。

# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES


其他不需要修改什么了,注意,ftpusers文件是一个黑名单,里面的用户不可以登录ftp,当然,也可以编程白名单,修改/etc/pam.d/vsftpd,将deny修改为allow(没有试过,据说这个可以,但是意义不大),白名单可以使用user_list文件
auth       required     pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed


二:添加用户

1.添加用户,使用 -d用来指向主目录  最后加上用户名

[root@localhost vsftpd]# useradd -d /home/test test
[root@localhost vsftpd]# passwd test  	  //修改密码,可能修改密码的时候会无法通过linux校验,root用户无视就好,连续输入两次
2.修改用户的权限
[root@localhost vsftpd]# usermod -s /sbin/nologin test    //用户无法通过xshall登录(如果想使用该用户通过xftp管理的,可以不设置)注:笔者在修改为这个状态以后,无法上传文件,也无法登陆,求解答。
[root@localhost vsftpd]# usermod -d /usr/test test        //修改用户主目录到user/test
[root@localhost vsftpd]# usermod -s /bin/bash test       //还原状态
用户权限可以修改配置文件,不过还没有试过,以后补充

[root@localhost vsftpd]# vi /etc/shells 


三:异常处理

1.500,在linux中输入一条命令,原因未知,之后再看

500 OOPS: cannot change directory:/home/test
500 OOPS: priv_sock_get_cmd
命令如下:

[root@localhost vsftpd]# setsebool -P ftp_home_dir 1


2.530
530 Permission denied.

确认黑名单中是否有你的用户

530 Login incorrect.
我的原因是权限给了/sbin/nologin ,将其调回预设就好了










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值