I've recently created my first server on Amazon EC2 (more on that soon) and I needed to move some stuff over. Here's how to setup a secure FTP server and configure it for your LAMP.
First, install the ftp software:
apt-get install vsftpd
Next, edit /etc/vsftpd.conf and uncomment or change the following:
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
connect_from_port_20=YES
guest_enable=NO
Add following lines at the end of file:
pasv_enable=YES
pasv_min_port=1044
pasv_max_port=1048
Next, you'll want to create a local user and a home directory where files will be saved. This keeps your www directory safe from intrusion. Upon connecting over FTP you'll be able to see and read from anywhere on the system, but only upload to one directory.
adduser ftp_user
passwd ftp_user
mkdir /home/ftp_user
chown ftp_user:users /home/ftp_user
You might only need the first command as your distro will take care of all the rest by prompting you.
Now you need to restart the ftp server to load the new configuration:
/etc/init.d/vsftpd restart
If you are wondering why I chose to restrict the passive ports to 1044 - 1048, this is because Amazon blocks all ports unless specifically allowed by the security group. You will need to open those ports in your Amazon Console. Click Security Groups, chose your group, click the Inbound tab and create a new Custom TCP rule. Specify ports 1044-1048, click Add Rule and Apply Rule Changes.
Presto! You can now connect to your LAMP over FTP using ftp_user. Your files will be uploaded to /home/ftpuser
No comments:
Post a Comment