Linux我用 Linux

Ubuntu FTP服务器搭建,配置修改,所遇问题解决

2017-11-14  本文已影响29人  莱昂纳多91

1.安装

sudo apt-get install vsftpd
这样安装后,配置文件在 /etc 下即: /etc/vsftpd.conf
备份默认配置
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
下面就是修改配置文件了,此时,我们需要明确的,就是需求,我们的需求如下:

1,一台win服务器定时(每两分钟)向一台Ubuntu服务器(本机器)发送一个文档。
2,该win机只能访问固定目录,不能全局访问
3,该win机对应用户名不能ssh登录Ubuntu服务器
4,另创建一个可以全局访问的用户
5,为Ubuntu服务器上的几个用户开通ftp权限

注意,最终解决的方法可能并非最优方法。

2.配置文件修改/etc/vsftpd.conf

3.结果展示

登录过程 登陆成功 网页登录

4.所遇问题

解决方法见此处

If you're using vsftpd with chroot local user option and write enable like this:
write_enable=YES
chroot_local_user=YES
and you're getting following error when you log-in through ftp:
500 OOPS: vsftpd: refusing to run with writable root inside chroot()
you can fix the problem with adding following line to /etc/vsftpd.conf and restart the vsftpd service:
allow_writeable_chroot=YES

这是因为如果配置中开启了chroot来控制用户路径(chroot_local_user=YES 说明用户无法跳出自己的初始根目录而去访问他人的目录),则用户不能再具有在该用户根目录下的写的权限。所以,要添加配置项allow_writeable_chroot=YES以开启根目录(非系统根目录,而是用户登录后所在的最上级目录)下写权限。

解决方法见此处

If you are not using PAM, then vsftpd will do its own check for a valid
user shell in /etc/shells. You may need to disable this if you use an invalid
shell to disable logins other than FTP logins. Put check_shell=NO in your
/etc/vsftpd.conf.

或者

Look at check_shell in vsftpd.conf:
Note! This option only has an effect for non-PAM builds of vsftpd.
If disabled, vsftpd will not check /etc/shells for a valid user
shell for local logins.
Default: YES
You can add '/usr/sbin/nologin' to /etc/shells. Simple and easy solution.
Another one is to change vsftpd.conf/PAM configuration.
Comment out this "auth ..." line in PAM case:
$ grep shells /etc/pam.d/vsftpd
auth required pam_shells.so

原因是vsftpd配置文件的check_shell默认是开启的
当你的用户当初创建时是用的-s /bin/false or -s bin/nologin
ftp会拿这个和/etc/shells文件比对,如果不包含,则报错。所以,
你可以把check_shell设置为NO
或者把bin/nologin添加进/etc/shells来解决此问题。
又或者,找到vsftpd对应的pam文件/etc/pam.d/vsftpd,把auth required pam_shells.so这一行注释掉。

上一篇 下一篇

猜你喜欢

热点阅读