Skip to content

Instantly share code, notes, and snippets.

@rikka0w0
Last active May 8, 2024 14:27
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rikka0w0/32678ec92fe210ffaf1c0f73e631c0bc to your computer and use it in GitHub Desktop.
Save rikka0w0/32678ec92fe210ffaf1c0f73e631c0bc to your computer and use it in GitHub Desktop.
[vsftpd]Setup anonymous upload and download FTP server

Install vsftpd

# Install
sudo apt update
sudo apt install vsftpd
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig

# Firwall rules
sudo ufw allow ftp-data
sudo ufw allow ftp
sudo ufw status

# Preparing Space for Files
sudo mkdir -p mapftp
sudo chown nobody:nogroup mapftp
echo "vsftpd test file" | sudo tee mapftp/test.log
sudo mkdir mapftp/maps/
sudo chmod a+rwx mapftp/maps/

Configure Anonymous Access

  • Edit /etc/vsftpd.conf
  • Change the following:
  1. anonymous_enable=YES to allow anonymous access
  2. write_enable=YES to enable uploading
  3. anon_upload_enable=YES to enable anonymous uploading
  4. anon_mkdir_write_enable=YES to enable anonymous directory creation
  • Append the following to the end: 1.anon_umask=022 so that new file will be readable by groups and other users. Uploaded files will have a permittion set to the value of file_open_mode (by default, 0666) subtracted by anon_umask.
  1. anon_other_write_enable=YES to enable anonymous deletion and renaming
  2. anon_root=xxx/mapftp sets the root folder for anonymous logins
  3. no_anon_password=YES stops prompting for a password on the command line.
  4. hide_ids=YES shows the user and group as ftp:ftp, regardless of the owner.
  5. pasv_min_port=40000 and pasv_max_port=50000 limits the range of ports that can be used for passive FTP
  • Optionally changes the listening port:
  1. listen_port= followed by port number

Conclusion

On Linux, use the ftp command to access the server, e.g. ftp -p 192.168.0.2 then followed by anonymous as the username. On Windows, use Windows Explorer or other FTP tools.

@MetaNova
Copy link

While not immediately useful for me, this outline was invaluable in helping someone else configure vsftpd to accept anonymous connections. Worked like a charm. Thank you for putting this together.

@deb-admin
Copy link

I used Debian 10. I tried it, but it didn't work. Why

@jm20122012
Copy link

jm20122012 commented Oct 10, 2020

What is the purpose of the "maps" directory inside "mapftp"?

@3nt3
Copy link

3nt3 commented Feb 27, 2022

@deb-admin same on ubuntu 21.10

@Snuupy
Copy link

Snuupy commented Dec 17, 2023

works Ubuntu 23.10

@patrick-douglas
Copy link

After the setup I'm getting the following error:

Connecting to 192.168.1.10:21... connected.
Logging in as anonymous ... 
The server refuses login.
Retrying.

Im running the following command wget ftp://192.168.1.10/viral.1.1.genomic.fna
How can I fix it?

Thank you in advance
:D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment