wiki:FTP

Version 3 (modified by krit, 10 months ago) (diff)

--

FTP server

Ref here

  1. install vsftp
    $ apt install vsftpd
    
  2. cp config to backup
    $ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig
    
  3. edit config /etc/vsftpd.conf
    listen=YES
    listen_ipv6=NO
    connect_from_port_20=YES
    anonymous_enable=NO
    local_enable=YES
    write_enable=YES
    chroot_local_user=YES
    allow_writeable_chroot=YES
    secure_chroot_dir=/var/run/vsftpd/empty
    pam_service_name=vsftpd
    pasv_enable=YES
    pasv_min_port=40000
    pasv_max_port=45000
    userlist_enable=YES
    userlist_file=/etc/vsftpd.userlist
    userlist_deny=NO
    
  4. Add the user in existing Linux user to the allowed FTP users list: in ex. allow user demo
    $ echo "demo" | tee -a /etc/vsftpd.userlist
    
  5. restart /etc/init.d/vsftpd restart or systemctl restart vsftpd

FTP server with pyftpdlib

krit mez NetProg$ python3 -m pyftpdlib -u demo -P test
[I 2024-02-15 14:53:57] concurrency model: async
[I 2024-02-15 14:53:57] masquerade (NAT) address: None
[I 2024-02-15 14:53:57] passive ports: None
[I 2024-02-15 14:53:57] >>> starting FTP server on 0.0.0.0:2121, pid=2026 <<<
[I 2024-02-15 14:54:16] 127.0.0.1:45522-[] FTP session opened (connect)
[I 2024-02-15 14:54:25] 127.0.0.1:45522-[demo] USER 'demo' logged in.