There is a collection of some un/official packages & modules for Python. Most of them are included in x64 .
Today I will approach the system using few lines of Python code :
– Python code : FTP client
– CentOS server : FTP server
Let’s get started !
FTP uses 2 port : 21 and (sometimes) 20 if the server is in active mode – or a random port (we’ll see them in this posting)
First of all, you need to install vsftp & ftp on your Server, by using those commands
yum install -y vsftpd #this one is for ftp server yum install -y ftp #this one is for ftp client service vsftpd start
Check whether FTP service is listening on port 21
Alright, that’s for the server-side, now at your client, open Python IDLE and run this
from ftplib import FTP f = FTP('ip_address_my_ftp_server') f.login('anonymous','anonymous') #I'm using anonymous login #f.quit() #omit this line, I'll explain below
Let’s check the netstat again and you’ll see what’s happening here :
There you go “126.96.36.199:24567” is my computer’s ip address and the port number which the ftp-server randomized it (passive mode).
And because f.quit() wasn’t executed, so that the connection is still open, that’s why you see the line “ESTABLISHED” above. If f.quit() executed – the connection will close before you can see anything happen.
Try as many time as you can, and take a look at this picture – I was using “f.quit()” to close a connection to the CentOS FTP server :
Have fun, I will write more about this in the next few days, we’re just scratching the surface, but it’s fun, right?