0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
阅读:566回复:2

vsftpd INTERNET_SITE + VITURAL_HOST

楼主#
更多 发布于:2005-09-02 10:30
放在这里看着方便。
NND,居然还要用到xinetd

/usr/share/doc/vsftpd/EXAMPLE/INTERNET_SITE/README
This example shows how you might set up a (possibly large) internet facing
FTP site.

The emphasis will be on security and performance.

We will see how by integrating vsftpd with xinetd, we get a powerful
combination.

Step 1) Set up your xinetd configuration file.

An example xinetd configuration file "vsftpd.xinetd" is supplied.
To install it:

cp vsftpd.xinetd /etc/xinetd.d/vsftpd

Let's look at the important content in this file and see what it does:

disable                 = no
socket_type             = stream
wait                    = no

This says that the service is active, and it is using standard TCP sockets.

user                    = root
server                  = /usr/local/sbin/vsftpd

The server program /usr/local/sbin/vsftpd is used to handle incoming FTP
requests, and the program is started as root (vsftpd will of course quickly
drop as much privilege as possible). NOTE! Make sure that you have the vsftpd
binary installed in /usr/local/sbin (or change the file path in the xinetd
file).

per_source              = 5
instances               = 200

For security, the maximum allowed connections from a single IP address is 5.
The total maximum concurrent connections is 200.

no_access               = 192.168.1.3

As an example of how to ban certain sites from connecting, 192.168.1.3 will
be denied access.

banner_fail             = /etc/vsftpd.busy_banner

This is the file to display to users if the connection is refused for whatever
reason (too many users, IP banned).

Example of how to populate it:
echo "421 Server busy, please try later." > /etc/vsftpd.busy_banner

log_on_success          += PID HOST DURATION
log_on_failure          += HOST

This will log the IP address of all connection attempts - successful or not,
along with the time. If an FTP server is launched for the connection, it's
process ID and usage duration will be logged too. If you are using RedHat
like me, this log information will appear in /var/log/secure.


Step 2) Set up your vsftpd configuration file.

An example file is supplied. Install it like this:

cp vsftpd.conf /etc

Let's example the contents of the file:

# Access rights
anonymous_enable=YES
local_enable=NO
write_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO

This makes sure the FTP server is in anonymous-only mode and that all write
and upload permissions are disabled. Note that most of these settings are
the same as the default values anyway - but where security is concerned, it
is good to be clear.

# Security
anon_world_readable_only=YES
connect_from_port_20=YES
hide_ids=YES
pasv_min_port=50000
pasv_max_port=60000

These settings, in order
- Make sure only world-readable files and directories are served.
- Originates FTP port connections from a secure port - so users on the FTP
server cannot try and fake file content.
- Hide the FTP server user IDs and just display "ftp" in directory listings.
This is also a performance boost.
- Set a 50000-60000 port range for passive connections - may enable easier
firewall setup!

# Features
xferlog_enable=YES
ls_recurse_enable=NO
ascii_download_enable=NO
async_abor_enable=YES

In order,
- Enables recording of transfer stats to /var/log/vsftpd.log
- Disables "ls -R", to prevent it being used as a DoS attack. Note - sites
wanting to be copied via the "mirror" program might need to enable this.
- Disables downloading in ASCII mode, to prevent it being used as a DoS
attack (ASCII downloads are CPU heavy).
- Enables older FTP clients to cancel in-progress transfers.

# Performance
one_process_model=YES
idle_session_timeout=120
data_connection_timeout=300
accept_timeout=60
connect_timeout=60
anon_max_rate=50000

In order,
- Activates a faster "one process per connection" model. Note! To maintain
security, this feature is only available on systems with capabilities - e.g.
Linux kernel 2.4.
- Boots off idle users after 2 minutes.
- Boots off idle downloads after 5 minutes.
- Boots off hung passive connects after 1 minute.
- Boots off hung active connects after 1 minute.
- Limits a single client to ~50kbytes / sec download speed.

Step 3) Restart xinetd.

(on RedHat)
/etc/rc.d/init.d/xinetd restart

If you run into problems, check:
1) Your /etc/xinetd.d directory only has one FTP service.


/usr/share/doc/vsftpd/EXAMPLE/VIRTUAL_HOSTS/README
This example shows how you might set up virtual hosts. Virtual hosting is
where different clients access your machine on different IP addresses (virtual
IPs) and get redirected to different ftp sites.

For example, if your machine responds to two IPs - 127.0.0.1 and 127.0.0.2,
you could have the two different IPs represent two totally different FTP sites.

For this example, we are going to build on the "INTERNET_SITE" example.

Step 1) Set up a virtual IP address.

ifconfig eth0:1 192.168.1.10 up
(the standard IP address is 192.168.1.2)
(note - this isn't quite complete, the route for local connects hasn't been
added, but it will do for now)


Step 2) Create a user / location for the new virtual site.

useradd -d /var/ftp_site2 ftp_site2
chown root.root /var/ftp_site2
chmod a+rx /var/ftp_site2
umask 022
mkdir /var/ftp_site2/pub
echo "test" > /var/ftp_site2/pub/content


Step 3) Modify the existing site to respond to the primary IP.

Edit /etc/xinetd.d/vsftpd, and add the config line:

bind = 192.168.1.2


Step 4) Create the new site, responding on the virtual IP.

cp /etc/xinetd.d/vsftpd /etc/xinetd.d/vsftpd2

Edit vsftpd2, and change
- The bind line to refer to the IP address 192.168.1.10
- Add the line
server_args = /etc/vsftpd_site2.conf

This launches this FTP site with a different vsftpd configuration file.

cp /etc/vsftpd.conf /etc/vsftpd_site2.conf

Add two lines:
ftp_username=ftp_site2
ftpd_banner=This is the alternative FTP site.


Step 5) Restart xinetd and test!

/etc/rc.d/init.d/xinetd restart

[chris@localhost vsftpd]$ ftp 192.168.1.2
Connected to 192.168.1.2 (192.168.1.2).
220 ready, dude (vsFTPd 1.1.0: beat me, break me)
Name (192.168.1.2:chris): [chris@localhost vsftpd]$
[chris@localhost vsftpd]$ ftp 192.168.1.2
Connected to 192.168.1.2 (192.168.1.2).
220 ready, dude (vsFTPd 1.1.0: beat me, break me)
Name (192.168.1.2:chris):
530 This FTP server is anonymous only.
Login failed.
ftp> quit
221 Goodbye.

[chris@localhost vsftpd]$ ftp 192.168.1.10
Connected to 192.168.1.10 (192.168.1.10).
220 This is the alternative FTP site.
Name (192.168.1.10:chris):
530 This FTP server is anonymous only.
Login failed.
ftp>
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
1C#
发布于:2005-09-02 11:54
Re:vsftpd INTERNET_SITE + VITURAL_HOST
郁闷了帮俺配一下~~懒得弄。。。。
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
suchasplus
作家
作家
  • 铜币16枚
  • 威望11点
  • 贡献值1点
2C#
发布于:2005-09-02 11:09
Re:vsftpd INTERNET_SITE + VITURAL_HOST
我继续郁闷中
The history of these days will be written in blood... By crushing the armies of our enemy, by seizing the weapons they thought to turn against us, we were fighting for our very existence!
游客

返回顶部