I have a script that should connect to a FTP
from ftplib import FTP
with FTP(\'IP\') as ftp:
ftp.login(user=\'my user\', passwd=\'my password\')
ftp.cwd(\
After using filezilla to debug the method, turn out that our FTP returned 0.0.0.0 despite we defined in /etc/vsftpd.conf
pasv_adress=IP
this post helped us : https://www.centos.org/forums/viewtopic.php?t=52408
You have to comment
listen_ipv6=YES
and enable
listen=YES
in /etc/vsftpd.conf
Also you can override the ftplib's class FTP if you can't access to vsftpd.conf of the FTP
class CustomFTP(ftplib.FTP):
def makepasv(self):
if self.af == socket.AF_INET:
host, port = ftplib.parse227(self.sendcmd('PASV'))
else:
host, port = ftplib.parse229(self.sendcmd('EPSV'), self.sock.getpeername())
if '0.0.0.0' == host:
""" this ip will be unroutable, we copy Filezilla and return the host instead """
host = self.host
return host, port
to force the previous host if '0.0.0.0'
is send