Cosmos.Network.Ftp 2.0.2

dotnet add package Cosmos.Network.Ftp --version 2.0.2
                    
NuGet\Install-Package Cosmos.Network.Ftp -Version 2.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cosmos.Network.Ftp" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cosmos.Network.Ftp" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Cosmos.Network.Ftp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cosmos.Network.Ftp --version 2.0.2
                    
#r "nuget: Cosmos.Network.Ftp, 2.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cosmos.Network.Ftp@2.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cosmos.Network.Ftp&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Cosmos.Network.Ftp&version=2.0.2
                    
Install as a Cake Tool

<h1 align="center">CosmosFTP Server 🚀</h1> <p> <a href="https://www.nuget.org/packages/Cosmos.Network.Ftp/" target="_blank"> <img alt="Version" src="https://img.shields.io/nuget/v/Cosmos.Network.Ftp.svg" /> </a> <a href="https://github.com/CosmosOS/CosmosFtp/blob/main/LICENSE.txt" target="_blank"> <img alt="License: BSD Clause 3 License" src="https://img.shields.io/badge/license-BSD License-yellow.svg" /> </a> </p>

CosmosFTP is an FTP server made in C# for the Cosmos operating system construction kit.

Version 2 is for Cosmos Gen3 kernels (NativeAOT). It is a plain .NET library over System.Net.Sockets and System.IO, which a Gen3 kernel runs on its own network stack and VFS. For Cosmos Gen2 (Cosmos.System2), use Cosmos.Network.Ftp 1.x.

Usage

Add the package to your kernel .csproj:

<ItemGroup>
    <PackageReference Include="Cosmos.Network.Ftp" Version="2.0.0" />
</ItemGroup>

The kernel needs networking and storage (CosmosEnableNetwork, CosmosEnableStorage, both on by default), an IP configuration (DHCP or static) and a mounted filesystem. Listen() serves every client on the calling thread until Close() is called, so start it on a thread of its own to keep your shell:

using System.Threading;
using Cosmos.Network.Ftp;

FtpServer server = new("/mnt")
{
    // Optional: left out, any user name logs in with any password.
    Authenticate = (user, password) => user == "cosmos" && password == "cosmos",
    // Optional: one line per connection, command and failure.
    Log = message => Cosmos.Kernel.System.Diagnostics.Log.WriteString(message + "\n"),
};

new Thread(server.Listen).Start();

// Later, to stop serving:
server.Close();

Clients see the served directory as / and cannot leave it. The server speaks RFC 959 with the commands common clients use: USER, PASS, PWD, CWD, CDUP, LIST, NLST, RETR, STOR, APPE, SIZE, DELE, MKD, RMD, RNFR/RNTO, PASV, EPSV, PORT, EPRT, FEAT, SYST, TYPE, NOOP and QUIT.

Data connections

Passive mode is the one to use. Each passive transfer listens on a port from PassivePortMin to PassivePortMax (50000 to 50009 by default). Active mode (PORT, EPRT) only connects back to the address the client is connected from, so it does not work through NAT.

Reaching a kernel running in QEMU

With QEMU user-mode networking, forward the control port and every passive port to the guest. With the Cosmos CLI:

cosmos run --hostfwd tcp::2121-:21 --hostfwd tcp::50000-:50000 --hostfwd tcp::50001-:50001  # and so on, up to 50009

A smaller range means fewer rules: PassivePortMin = 50000, PassivePortMax = 50000 needs a single one. Then connect to localhost:2121 in passive mode, for example curl ftp://localhost:2121/. A PASV reply names the guest's own address, 10.0.2.15, which the host cannot reach. curl and Python's ftplib ignore it and connect to the address they reached the server at, and EPSV names no address at all, but FileZilla connects where the reply says. For it, set PassiveAddress = IPAddress.Loopback, so that PASV names 127.0.0.1.

Security

FTP sends everything in the clear, password included. Serve it on a network you trust.

Building and testing

dotnet test Cosmos.Network.Ftp.slnx

The tests run the server on the host, over loopback, against a raw FTP client.

Port of a C written Epitech project: NWP_myftp_2019

Authors

👤 @valentinbreiz

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2022-2026 CosmosOS.

This project is BSD Clause 3 licensed.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 74 10/2/2026
2.0.1 73 10/2/2026
2.0.0 102 10/1/2026