现在的位置: 首页 > 综合 > 正文

ubuntu 12.04使用vsftpd建立FTP的经验整理

2013年08月06日 ⁄ 综合 ⁄ 共 3344字 ⁄ 字号 评论关闭

如果要深入学习,可以参考

http://book.51cto.com/art/200810/92757.htm是一本书,我觉得有时间还是得先看完这个

http://os.51cto.com/art/201008/222036.htm专题,扩展阅读

Web信息

vsftpd主页是vsftpd.beasts.org。

HOWTO

FTP mini-HOWTO

vsftpd匿名登录

网络上很少提及匿名登录的,可能不安全吧,但是有时候急着搭建FTP,就有必要配置了。

重点是加这个命令 anon_root=/var/run/vsftpd/empty  这个可以自定义,有些系统默认路径是/var/ftp

这个empty文件夹保持755权限(权限不对是进不去的),然后进入里面建立一个新的文件夹user(名字可以自定义),权限为777,就可以在这个user下操作

好用的配置

简介:这个命令可以用来为每个用户创建单独的目录,或者其它权限和功能设置。

user_config_dir

指定一个目录,该目录包含一些以本地用户的用户名来命名的文件。每一个这样的文件(模仿vsftpd.conf)都包含着一些参数,这些参数覆盖(根据每个用户)默认参数以及在vsftpd.conf中指定的参数。举例来说,假设user_config_dir设置为/etc/vsftpd/user_conf。如果默认的配置文件(/etc/vsftpd/vsftpd.conf)设置了idlesession_timeout=300,而Sam的个人配置文件(/etc/vsftpd/user_conf/sam)设置了idlesession_timeout=1200,那么除了Sam之外,所有用户的会话无活动超时时间都为300秒,而Sam的会话超时时间为1
200秒。

默认值:无

http://book.51cto.com/art/200810/92809.htm

猜想可以利用这个方法,为不同用户指定不同到根目录,这个还没实验。默认情况下,所有登录用户是用同一个根目录的。

注意事项

listen

若设置为YES,则会使vsftpd在独立模式下运行;而若设置为NO,则会使其在普通模式下运行。

如果不懂,就选YES,这是直接启动vsftpd,如果选了默认到NO,则会经过xinet守护程序按需运行vsftpd,这个还需要其它设置,我照着做一遍,没成功。

如果没时间去学习vsftpd,快速配置,则看这个

网络上很多经验,都是说怎么配置匿名登录的,但是照着弄没配置成功,因此改为用户名登录,参考基础教程

http://wiki.ubuntu.org.cn/Vsftpd%E5%AE%9E%E4%BE%8B

http://wiki.ubuntu.org.cn/Vsftpd

补充:

用户名登录,指的是Linux系统到用户。一开始,我还以为是FTP自己保留账户,这是错的。正因为如此,需要在Linux下新建一个ftpuser账户,和一个ftp组,并要求建立/home/ftpuser根目录,上面到教程会把/var/ftp/链接到这个根目录,然后,你登录ftpuser后,根目录会看到/var/ftp下到内容。

ftpuser的权限配置如下:

GitServer:/home$ ll
total 28
drwxr-xr-x  5   root    root    4096 Jul  9 17:55 ./
drwxr-xr-x 24 root    root    4096 Jul  9 12:04 ../
drwxr-xr-x  3 root    root    4096 Jul  4 00:51 .ecryptfs/
drwx------  2  ftpuser ftp     4096 Jul  9 17:55 ftpuser/
drwx------ 32 norton  norton 12288 Jul  9 17:46 norton/

GitServer:/var/ftp$ ll
total 16
drwxr-xr-x  3 root root 4096 Jul  9 17:32 ./
drwxr-xr-x 15 root root 4096 Jul  9 16:54 ../
-rw-r--r--  1 root root   31 Jul  9 17:32 .message
drwxrwxr-x  3 root ftp  4096 Jul  9 18:10 pub/

使用到的命令:参照下面的常用命令

常用命令

查看是否打开21端口

$ sudo netstat -npltu | grep 21
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      15601/vsftpd    

useradd

passwd

chown 更改文件拥有者

chmod

touch

rm

mv

mkdir

locate 查看文件所在的位置 如locate nologin。具体说明可以man locate看看。

updatedb 如果locate不到安装过的文件,就sudo updatedb更新一下数据库

安全性配置

注意,FTP登录用的账户是系统账户,但传输过程中,密码是明文的,所以不安全,要限制网络账户的shell,使用nologin,则不能用这个帐号登录系统。帐号丢了也不那么危险。

用sudo权限打开/etc/passwd

把网络账户的shell改为nologin。我到路径在/usr/sbin/nologin.

如果不知道,可以输入locate nologin查看位置

常见错误汇总

1.500 OOPS: vsftpd: refusing to run with writable root inside chroot()
Login failed.
文档权限应该设置为不可写

2.After following the tutorial and then trying to use FileZilla to copy a file to the home/username/files directory, I was getting this error: open for write:

permission denied
Error: File transfer failed

I got this working by executing: chown username home/username/files

After executing that I was able to copy a test file to the files folder.

3.路径问题
To see what permissions you have already set for any directory

sudo ls -la /var/www/

Replace "/var/www/" with the directory you need to check!

3.dark@dark-laptop:~$ ftp 14.14.14.14
ftp: connect: Connection refused
一般是vsftpd.conf内容写错了,请检查拼写错误

4.Name (14.14.14.14:dark): customer
331 Please specify the password.
Password:
500 OOPS: missing value in config file for: /home/ftpuser/
Login failed.
421 Service not available, remote server has closed connection

这是因为我只写了地址
Vsftp.conf文件配置错误。
注意这里的内容前面不要空格,=号前后不要有空格。
=后面一定要有内容。
否则注释掉。

5.Name (14.14.14.14:dark): customer
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/home/ftpuser/
Login failed.

不存在这样到路径

6. 331 Please specify the password.
Password:
530 Login incorrect.
Login failed.

密码错误,查看密码配置文件是否正确

进阶配置

学习配置xinet,这是一个提供高安全的超级守护进程,帮助管理各种网络服务,甚至系统服务。

http://wordpress.facesoho.com/server/what-is-xinetd.html

抱歉!评论已关闭.