Passive FTP is a variant of the FTP, a network protocol for transmitting files between computers over TCP/IP connections.
Two types of channels have been implemented,
- Control/Command channel : Used to exchange commands and replies to commands between client and server
- Data channel : Used to send (recieve) a file to (from) a host
A naive authentication mechanism has also been implemented to make the clients perform R/W operations in a dedicated directory. The program prompts the user to enter username and password, if the entered username does not exist in users.txt
file, it is considered a register attempt. The user is registered and a new directory is created for that user. If the username matches an entry in users.txt
, the program checks the corresponding password and the attempt is considered login.
The server listens for control channel connection requests on PORT
and for data channel connection requests on PORT+1
. A control channel is established when a client connects to the server. Data channels are created on request (GET/PUT). This mechanism enables multiple clients to perform multiple GET/PUT operations simultaneously.
Only one control channel exists between a client and the server but multiple data channels may exist. Data channels are closed automatically when the designated file transfer is completed.
-
GET : Downloads a file from the logged-in user's directory from the server and saves it in the
CLIENT
directory on the client.GET <filename> [-b (for binary mode)] $
-
LIST : Description: List all files present in logged in clients's directory on the server.
LIST $
-
PUT : Uploads a file from the
CLIENT
directory from client to the logged-in user's directory on the server.PUT <filename> [-b (for binary mode)] $
-
close : Disconnect the client from server.
close $
-
Clone this repo
git clone https://github.com/rahulpathak-github/passiveFTP
-
Run the following command to build and move into the
build
directorycd passiveFTP && sh build.sh && cd build
-
Run the server
./server <PORT>
-
Run the client
./client <IP> <PORT>
Note: Current implemetation allows only one connection from one IP address.