Score:0

vsftpd FTP server on Ubuntu 20.04

cn flag

I am experimenting with this tutorial to setting up an FTP server on an Ubuntu 20.04 instance and seeing if I can push a CSV file to it from a Windows 10 instance with Python.

On the linux side I have the settings exactly like the tutorial states when going thru modifying the vsftd config file with nano:

listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
ssl_enable=YES
user_sub_token=$USER
local_root=/home/$USER/ftp
pasv_min_port=30000
pasv_max_port=31000
userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

On the client side which is a Windows 10 machine on LAN with the Ubuntu instance I have this Python file to try and push the CSV file to the FTP server running on the Ubuntu instance. I am sort of lost on what I would use for the FTP server authentication as well as the port number to specify that the FTP server is running on.

Python 3.9 from Windows 10:

from ftplib import FTP


FTP_HOST = "192.168.0.105"
#FTP_PORT = 7021
FTP_USER = "ben"
FTP_PASS = "ben"

print("I'm working...")
ftp = FTP()
#ftp.connect(FTP_HOST, FTP_PORT)

ftp.connect(FTP_HOST)
ftp.login(FTP_USER, FTP_PASS)

# local file name you want to upload
filename = "madison_office_2020.csv"
with open(filename, "rb") as file:
    ftp.storbinary(f"STOR {filename}", file)

ftp.quit()

In the Python script I have the port number commented out and the username/password is the user Ubuntu Linux user currently running on the Linux instance. Any tips appreciated this is the traceback that almost seems like a file or directory permissions error. Any tips appreciated not a lot of Linux wisdom here on how to verify file permissions.

Traceback (most recent call last):
  File "C:\Users\bbartling\Desktop\ftp_client\client_side_push.py", line 20, in <module>
    ftp.storbinary(f"STOR {filename}", file)
  File "C:\Python39\lib\ftplib.py", line 498, in storbinary
    with self.transfercmd(cmd, rest) as conn:
  File "C:\Python39\lib\ftplib.py", line 393, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python39\lib\ftplib.py", line 359, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "C:\Python39\lib\ftplib.py", line 281, in sendcmd
    return self.getresp()
  File "C:\Python39\lib\ftplib.py", line 254, in getresp
    raise error_perm(resp)
ftplib.error_perm: 550 Permission denied.

One last note is this directory does exist. /var/run/vsftpd/empty I just dont know how to check user permissions for this directory. Try this below I probably messed it up even worse, not a lot of wisdom here any tips appreciated:

sudo chown -R ben: /var/run/vsftpd/empty
sudo chown -R ben /var/run/vsftpd/empty
sudo chown -R 755 /var/run/vsftpd/empty

Now if I try and check permissions, not sure if this is correct way with just ls -al this will give me ls: cannot open directory '.': Permission denied

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.