通过修改改/etc/hosts.allow 来实现访问控制 但是有个小问题(详见155楼(第11页))

上网、浏览、聊天、下载等
回复
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

通过修改改/etc/hosts.allow 来实现访问控制 但是有个小问题(详见155楼(第11页))

#1

帖子 243750496 » 2013-06-17 18:06

/etc/vsftpd.conf
listen=<YES/NO> :设置为YES时vsftpd以独立运行方式启动,设置为NO时以xinetd方式启动(xinetd是管理守护进程的,将服务集中管理,可以减少大量服务的资源消耗)
listen_port=<port> :设置控制连接的监听端口号,默认为21
listen_address=<ip address> :将在绑定到指定IP地址运行,适合多网卡
connect_from_port_20=<YES/NO> :若为YES,则强迫FTP-DATA的数据传送使用port 20,默认YES
pasv_enable=<YES/NO> :是否使用被动模式的数据连接,如果客户机在防火墙后,请开启为YES
pasv_min_port=<n>
pasv_max_port=<m> :设置被动模式后的数据连接端口范围在n和m之间,建议为50000-60000端口
message_file=<filename> :设置使用者进入某个目录时显示的文件内容,默认为 .message
dirmessage_enable=<YES/NO> :设置使用者进入某个目录时是否显示由message_file指定的文件内容
ftpd_banner=<message> :设置用户连接服务器后的显示信息,就是欢迎信息
banner_file=<filename> :设置用户连接服务器后的显示信息存放在指定的filename文件中
connect_timeout=<n> :如果客户机连接服务器超过N秒,则强制断线,默认60
accept_timeout=<n> :当使用者以被动模式进行数据传输时,服务器发出passive port指令等待客户机超过N秒,则强制断线,默认60
accept_connection_timeout=<n> :设置空闲的数据连接在N秒后中断,默认120
data_connection_timeout=<n> : 设置空闲的用户会话在N秒后中断,默认300
max_clients=<n> : 在独立启动时限制服务器的连接数,0表示无限制
max_per_ip=<n> :在独立启动时限制客户机每IP的连接数,0表示无限制(不知道是否跟多线程下载有没干系)
local_enable=<YES/NO> :设置是否支持本地用户帐号访问
guest_enable=<YES/NO> :设置是否支持虚拟用户帐号访问
write_enable=<YES/NO> :是否开放本地用户的写权限
local_umask=<nnn> :设置本地用户上传的文件的生成掩码,默认为077
local_max_rate<n> :设置本地用户最大的传输速率,单位为bytes/sec,值为0表示不限制
local_root=<file> :设置本地用户登陆后的目录,默认为本地用户的主目录
chroot_local_user=<YES/NO> :当为YES时,所有本地用户可以执行chroot
chroot_list_enable=<YES/NO>
chroot_list_file=<filename> :当chroot_local_user=NO 且 chroot_list_enable=YES时,只有filename文件指定的用户可以执行chroot
anonymous_enable=<YES/NO> :设置是否支持匿名用户访问
anon_max_rate=<n> :设置匿名用户的最大传输速率,单位为B/s,值为0表示不限制
anon_world_readable_only=<YES/NO> 是否开放匿名用户的浏览权限
anon_upload_enable=<YES/NO> 设置是否允许匿名用户上传
anon_mkdir_write_enable=<YES/NO> :设置是否允许匿名用户创建目录
anon_other_write_enable=<YES/NO> :设置是否允许匿名用户其他的写权限(注意,这个在安全上比较重要,一般不建议开,不过关闭会不支持续传)
anon_umask=<nnn> :设置匿名用户上传的文件的生成掩码,默认为077

==匿名用户==
先备份
<pre>sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.old

打开

sudo vi /etc/vsftpd.conf

允许匿名访问

# Allow anonymous FTP? (Disabled by default)
anonymous_enable=YES

[编辑] 上传文件

允许匿名上传

write_enable=YES
anon_mkdir_write_enable=YES
anon_upload_enable=YES

注意2点:(以下啥意思????)

1.匿名用户就是ftp,想要匿名用户写入,必须文件夹的权限为ftp可写。

2.匿名用户的根目录不允许写,所以根目录的权限绝对不能是ftp可写和其他用户可写,如果根目录所有者为ftp的话,所有者的权限也不能写。

所以解决方法是建个单独的public文件夹用于上传文件,设置其为ftp可写或”其他用户可写“

还可建个download文件夹只用于下载,设置其他用户没有写权限便可。

这是我的/etc/vsftpd.conf文件

# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=YES
#
# Run standalone with IPv6?
# Like the listen parameter, except vsftpd will listen on an IPv6 socket
# instead of an IPv4 one. This parameter and the listen parameter are mutually
# exclusive.
#listen_ipv6=YES
#
# Allow anonymous FTP? (Disabled by default)
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
#write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# If enabled, vsftpd will display directory listings with the time
# in your local time zone. The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# 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().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
# This option specifies the location of the RSA key to use for SSL
# encrypted connections.
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

为什么匿名登录看不见任何东西 而且无法写入
屏幕截图.png
但root就能看到主文件夹 但仍不能写入?
的屏幕截图.png
可是我已经chmod 777了
8的屏幕截图.png
上面那个我看不懂的wiki注意事项貌似解释了这个问题 是么?
可是没看懂具体他说的啥意思,求解释 谢了诸位神~
维基网址:http://wiki.ubuntu.org.cn/Vsftpd
上次由 243750496 在 2013-06-30 18:23,总共编辑 4 次。
头像
oneleaf
论坛管理员
帖子: 10454
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: wiki上的vsftp教程有一点不懂求解释

#2

帖子 oneleaf » 2013-06-17 19:34

显示下日志看看?
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#3

帖子 243750496 » 2013-06-17 20:56

oneleaf 写了:显示下日志看看?
咋显示???
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#4

帖子 243750496 » 2013-06-17 21:06

现在回到家里 共享这个ip 成这样了
9的屏幕截图.png
图.png
上次由 243750496 在 2013-06-17 22:07,总共编辑 1 次。
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#5

帖子 243750496 » 2013-06-17 21:26

另一台win7电脑成这样了
无标题0.png
无标题.png
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: wiki上的vsftp教程有一点不懂求解释

#6

帖子 eexpress » 2013-06-17 22:04

不是长期假设服务器的话,很多简单的方法搞ftpd。基本都是一句话。多搜索。
你这样一句一句的研究,眼睛也累啊。尤其夹杂着windows,,,难说清楚了。
● 鸣学
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#7

帖子 243750496 » 2013-06-17 22:07

我准备架设我们家的服务器
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#8

帖子 243750496 » 2013-06-17 22:09

eexpress 写了:不是长期假设服务器的话,很多简单的方法搞ftpd。基本都是一句话。多搜索。
你这样一句一句的研究,眼睛也累啊。尤其夹杂着windows,,,难说清楚了。
那大神能解答下
1.匿名用户就是ftp,想要匿名用户写入,必须文件夹的权限为ftp可写。

2.匿名用户的根目录不允许写,所以根目录的权限绝对不能是ftp可写和其他用户可写,如果根目录所有者为ftp的话,所有者的权限也不能写。

所以解决方法是建个单独的public文件夹用于上传文件,设置其为ftp可写或”其他用户可写“

还可建个download文件夹只用于下载,设置其他用户没有写权限便可。
这些啥意思
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#9

帖子 243750496 » 2013-06-17 22:18

我现在的问题是 明明按教程做的更改
sudo vi /etc/vsftpd.conf中的以下几条为图示:
# Allow anonymous FTP? (Disabled by default)
anonymous_enable=YES
write_enable=YES
anon_mkdir_write_enable=YES
anon_upload_enable=YES
1、按理说应该是匿名就可以访问并上传东西可是一上来首先要登录 不登录不让用 这首先就不对劲 用root(cc)2、登录后能看到主目录可是我没设共享主目录啊?这是其二 3、之前chmod 777 123 了应该允许读写了 可是仍然没法上传 我可已经是root用户了啊 而且又chmod 777 了怎么可能还不让写?

诸神们 请回答我这个小小的人类提出的问题
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: wiki上的vsftp教程有一点不懂求解释

#10

帖子 eexpress » 2013-06-17 22:29

你要钻研细节,找叶子。

家庭使用,直接上dlna嘛。各种设备互联。
● 鸣学
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#11

帖子 243750496 » 2013-06-17 22:54

之前是我没注意到代码前是有星#号的 对不起
现在的问题是照着代码做了匿名用户也能登录了
但是出现这个问题:
屏幕截图.png
头像
qy117121
论坛版主
帖子: 50586
注册时间: 2007-12-14 13:40
系统: Winbuntu
来自: 志虚国乌由市
联系:

Re: wiki上的vsftp教程有一点不懂求解释

#12

帖子 qy117121 » 2013-06-17 23:04

渠月 · QY   
本人只会灌水,不负责回答问题
无聊可以点一下→ http://u.nu/ubuntu

邮箱 chuan@ubuntu.org.cn
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#13

帖子 243750496 » 2013-06-17 23:25

可是貌似我的目录在/srv/ftp
1、我的那个root用户登录后却转到主目录怎么回事???
2、root登录后可以在主文件夹上传文件 者说明配置文件上传功能没问题了 但是我在/srv/ftp下新建了文件夹123 可是匿名登录后找不到啊?尽管赋予了777权限
找不到你付权也没用啊 为什么找不到??难道ftp服务器的文件夹不是/srv/ftp???
3、如何自定义ftp载入文件夹位置 不让他用/srv/ftp???
4、如何让root(cc)和匿名用户同用一个目录

注:
cc@thinkpad:~$ sudo find / -name ftp
[sudo] password for cc:
/var/lib/dpkg/alternatives/ftp
/var/ftp
/srv/ftp
/usr/lib/apt/methods/ftp
/usr/share/doc/ftp
/usr/bin/ftp
/etc/alternatives/ftp
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#14

帖子 243750496 » 2013-06-17 23:39

我在var/ftp下建立123 也找不到
243750496
帖子: 1038
注册时间: 2012-06-09 15:40

Re: wiki上的vsftp教程有一点不懂求解释

#15

帖子 243750496 » 2013-06-17 23:45

sudo mkdir /var/ftp/123
sudo chmod 777 /var/ftp/123
cc@thinkpad:~$ sudo service vsftpd restart
[sudo] password for cc:
vsftpd stop/waiting
vsftpd start/running, process 4542
cc@thinkpad:~$ ftp 192.xxx.xxx.xxx
Connected to 192.xxx.xxx.xxx.
220 (vsFTPd 3.0.2)
Name (192.xxx.xxx.xxx:cc): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

然后重启虚拟机就找到了
可用了
回复