Setup a FTP server on ubuntu under 1 minute
Want to create a FTP server on your raspberry pi or really any other linux server? Head to your terminal and type:
~/$ sudo apt-get install -y proftpd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
...
You’re done. Don’t believe me, head to your terminal:
~/$ ftp 127.0.0.1
Connected to 127.0.0.1.
220 ProFTPD Server (Debian) [::ffff:127.0.0.1]
Name (127.0.0.1:mickael):
331 Password required for mickael
Password:
230 User mickael logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwxr-xr-x 2 mickael mickael 4096 Jul 3 02:56 Desktop
drwxr-xr-x 7 mickael mickael 4096 Aug 4 13:22 Documents
drwxr-xr-x 13 mickael mickael 12288 Aug 6 15:20 Downloads
226 Transfer complete
ftp> quit
221 Goodbye.
Connected to 127.0.0.1.
220 ProFTPD Server (Debian) [::ffff:127.0.0.1]
Name (127.0.0.1:mickael):
331 Password required for mickael
Password:
230 User mickael logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwxr-xr-x 2 mickael mickael 4096 Jul 3 02:56 Desktop
drwxr-xr-x 7 mickael mickael 4096 Aug 4 13:22 Documents
drwxr-xr-x 13 mickael mickael 12288 Aug 6 15:20 Downloads
226 Transfer complete
ftp> quit
221 Goodbye.
Optional step: enable FTPS for better security
If you’re gonna expose the server over the internet, you should definitly enabled FTPS. To do this:
~/$ sudo openssl req -x509 -newkey rsa:2048 -keyout /etc/ssl/private/proftpd.key -out /etc/ssl/certs/proftpd.crt -nodes -days 365
Generating a RSA private key
................+++++
......................................+++++
writing new private key to '/etc/ssl/private/proftpd.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
~/$ sudo sed -i 's|#Include /etc/proftpd/tls.conf|Include /etc/proftpd/tls.conf|g' /etc/proftpd/proftpd.conf
~/$ cat > /etc/proftpd/tls.conf <<EOF
<IfModule mod_tls.c>
TLSEngine on
TLSLog /var/log/proftpd/tls.log
TLSRSACertificateKeyFile /etc/ssl/private/proftpd.key
TLSRSACertificateFile /etc/ssl/certs/proftpd.crt
TLSVerifyClient off
TLSRenegotiate none
TLSOptions NoSessionReuseRequired
</IfModule>
EOF
~/$ sudo systemctl restart proftpd
Generating a RSA private key
................+++++
......................................+++++
writing new private key to '/etc/ssl/private/proftpd.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
~/$ sudo sed -i 's|#Include /etc/proftpd/tls.conf|Include /etc/proftpd/tls.conf|g' /etc/proftpd/proftpd.conf
~/$ cat > /etc/proftpd/tls.conf <<EOF
<IfModule mod_tls.c>
TLSEngine on
TLSLog /var/log/proftpd/tls.log
TLSRSACertificateKeyFile /etc/ssl/private/proftpd.key
TLSRSACertificateFile /etc/ssl/certs/proftpd.crt
TLSVerifyClient off
TLSRenegotiate none
TLSOptions NoSessionReuseRequired
</IfModule>
EOF
~/$ sudo systemctl restart proftpd
proftpd is highly configurable, check their doc if you want to go further.