How To: Run an FTP Server from Home with Linux

Run an FTP Server from Home with Linux

File Transfer Protocol, or FTP, is a network protocol made for transferring files in a client and host fashion over a Transmission Control Protocol (TCP) network, such as the internet. FTP is integrated into most browsers, and you have probably used it before. It is a common way to host files and transfer them easily. To access an FTP, a login is required, unless the server is configured to use anonymous logins (like the Arch Linux mirrors).

In a home environment, having an FTP server can be a really cool thing. FTP is an easy way to host and share files between all of your computers, and even access your home FTP files when using Wi-Fi away from home. Beware, as FTP is an insecure protocol. A secure alternative is SFTP (SSH File Transfer Protocol).

Today in Null Byte, we are going to set up an FTP server daemon on our systems. This will allow us to:

  • Share files over the internet.
  • Share files outside of a Virtual Machine.
  • Escape a chroot.
  • Host your own file repository that can be modified by other users over the internet.

Requirements

  • Linux
  • Root privileges
  • Router administrator privileges
  • A router capable of port forwarding
  • Some files to share

Step 1 Download & Install the Daemon

Text in bold is a command that must be entered in a terminal emulator.

First, we have to install the FTP daemon of our choice. A daemon is just a program or service that runs in the background processes. I use vsftpd (very secure FTP daemon) for my FTP server. It is light on system resources, secure, small in size, and easy to configure.

  1. Download the vsftpd source from the official website.
  2. Change to your Downloads directory.
        cd ~/Downloads
  3. Configure the installation for your system.
        ./configure
  4. Compile and install vsftpd.
        make && sudo make install

Step 2 Move Files to the FTP Server

  1. Let's move our music to FTP for the example.
        sudo cp -R ~/music/* /srv/ftp/

Step 3 Configure & Start the Daemon

  1. Configure the daemon to not allow anonymous logging.
        From =YES to =NO.
  2. Depending on your distro, starting services is a different command. For Ubuntu, it is service. Arch uses rc.d.
        sudo rc.d start vsftpd

Step 4 Access the FTP Remotely on a Browser

Let's access our FTP from somewhere outside our network.

  1. Enable port forwarding for port 21.
  2. Go to whatismyip and write down your external IP address.
  3. Open up an internet browser on a computer from outside of the network and type the following into the address bar.
        ftp://<ip address>/music/
    You can also use wget.
        wget ftp://<ipaddress>/music/
  4. Browse your music folder!

Have fun playing with your own FTP server! Visit the Null Byte IRC and chat with all of us. You can also follow me on Twitter and Google+ for updates.

Image via webmastersbydesign

5 Comments

no glFTPd ? hehe

I would have added it, but since it requires extensive scripting, it would be impratical for inexperienced users :(.

Share Your Thoughts

  • Hot
  • Latest