pureftpd

如何在Amazon EC2上安装和配置Pure-FTPd
本文详细介绍了如何在Amazon EC2上安装并配置Pure-FTPd,包括安装步骤、创建FTP用户账户、配置FTP服务器、解决连接错误等问题,以及防火墙设置和端口开放。

1. 安装

参考:http://opensourceholic.com/2014/05/11/setup-ftp-account-on-amazon-ec2-using-pure-ftpd/

Install Pure-FTPd:

To install Pure-FTPD on Ubuntu run below command on terminal

sudo apt-get install pure-ftpd

Unlike most FTP servers, Pure-FTPd has almost no configuration files. It is all command-line driven.

Create an unprivileged user and group using the following commands:

sudo groupadd ftpgroup

sudo useradd -g ftpgroup -d /dev/null -s /etc ftpuser

sudo chown -R ftpuser:ftpgroup /home/ftpusers

Next create your ftpuser directory

sudo mkdir /home/ftpusers

This will be the home directory at /home/ftpusers. This will be the root of their access on the server if you create your users with jail access where they can’t move up to higher levels. You can also create a individual home directories for each user using symlink.

The ‘ftpgroup’ group and the ‘ftpuser’ user will be needed when you are setting up users in your ftp server.

Setup FTP user account:

Create a user directory or a home directory for user $USER. Replace $USER with your user name.

sudo mkdir /home/ftpusers/$USER

Create user $USER

sudo pure-pw useradd joe -u ftpuser -d /home/ftpusers/$USER

If you wish to create a admin user with full server access omit the -d /home/ftpusers/$USER parameter.

Create a user database

sudo pure-pw mkdb

Create symbolic links between the respective files. Use following commands to create a symbolic links.

sudo ln -s /etc/pure-ftpd/pureftpd.passwd /etc/pureftpd.passwd

sudo ln -s /etc/pure-ftpd/pureftpd.pdb /etc/pureftpd.pdb

sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/PureDB

Configure Pure-FTPd:
  • Disable UNIX authentication

root@ec2-user:~# echo no > /etc/pure-ftpd/conf/UnixAuthentication

  • Run as a daemon

root@ec2-user:~# echo "yes" > /etc/pure-ftpd/conf/Daemonize

  • Prohibit Anonymous

root@ec2-user:~# echo "yes" > /etc/pure-ftpd/conf/NoAnonymous

  • Enable chroot

root@ec2-user:~# echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone

  • Only IPV4

root@ec2-user:~# echo "yes" > /etc/pure-ftpd/conf/IPV4Only

All this configuration is for normal FTP server below are some configuration specific for Amazon EC2 Server

  • Enable Passive mode

root@ec2-user:~# echo "50000 50100" > /etc/pure-ftpd/conf/PassivePortRange

  • Access to public IP

root@ec2-user:~# echo "public_ip" > /etc/pure-ftpd/conf/ForcePassiveIP

Here put your EC2 server Public IP. Enable port range 50000-50100 and 21 in your amazon security group.

  • Restart Pure-FTPd

sudo /etc/init.d/pure-ftpd restart

And its done try to access your FTP account using your favorite FTP client ex Filezilla, gFTP.

Pure-FTPd commands:

Following are the parameters that you can use with pure-pw command. Look at Pure-FTPd documentation for list of options use pure-pw –help

-d <home directory> : chroot user (recommended)
-D <home directory> : don't chroot user
-z <time> : To allow access only between given time period
-y <max number of concurrent sessions>
-r <allow client ip>/<mask>
-R <deny client ip>/<mask>
-m : also update the /etc/pure-ftpd/pureftpd.pdb database

  • Update an existing User

sudo pure-pw usermod $user $options -m

  • Remove an existing User

sudo pure-pw userdel $USER -m

  • List out all Users 

sudo pure-pw list

  • Update the User/Password Database Manually

In case you forget -m option update the User/Password Database manually

sudo pure-pw mkdb

  • View Server Activity

sudo pure-ftpwho

2. ECONNREFUSED - Connection refused by server error

关闭防火墙:ufw disable

设置iptable:iptables -A INPUT -p tcp --dport 21 -j ACCEPT

iptables -A INPUT -p tcp --dport 20 -j ACCEPT

iptables -A INPUT -p tcp --dport 50000:50100 -j ACCEPT

    还是连不上。最后参考:http://adamschepis.com/blog/2011/02/23/pure-ftpd-passive-ftp-on-amazon-ec2/

     移除 ForcePassiveIP 127.0.0.1 参数,或者将其改为虚拟服务器的公网IP

      问题解决


注:云服务器如果有防火墙的话也要打开相关的端口


3. 修改用户工作目录

 pure-pw usermod riboud -u ftpuser -D /.

转载于:https://my.oschina.net/u/584525/blog/301294

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值