@ideadesignmedia/ftp
v1.0.3
Published
Run an explicit FTPS server on Windows using environment variables loaded from `config.json`.
Readme
FTPS Server on Windows (ftp-srv + @ideadesignmedia/config.js)
Run an explicit FTPS server on Windows using environment variables loaded from config.json.
Files
your-project/
├─ index.js
├─ config.json
└─ ftproot/ (your exposed root; inside you can link drives C, D, E)index.js
require("@ideadesignmedia/config.js");
require("@ideadesignmedia/ftp");
@ideadesignmedia/config.jsloadsconfig.jsonintoprocess.env.@ideadesignmedia/ftpstarts the FTP server using those env vars.
Example config.json
Use values similar to yours, but not identical. Adjust paths and IPs for your machine.
{
"FTPPORT": "21",
"FTPIP": "203.0.113.25",
"PASV_MIN": "50000",
"PASV_MAX": "50050",
"FTPUSERNAME": "siteuser",
"FTPPASSWORD": "ChangeMe!42",
"FTPPATH": "C:/ftproot",
"FTPBLACKLIST": ["node_modules", ".git"],
"FTPWHITELIST": ["uploads", "downloads"],
"PRIV": "C:/ftps/ftp.key",
"PUB": "C:/ftps/ftp.crt"
// Or use PFX:
// "PFX": "C:/ftps/ftps.pfx",
// "PFX_PASS": "changeThisPass"
}FTPPORT21 withtlsenabled means explicit FTPS (client must use AUTH TLS).FTPIPshould be your public IP for internet clients or your LAN IP for local testing.PASV_MINandPASV_MAXmust be opened in Windows Firewall and forwarded on your router if used over the internet.FTPPATHis the server root that users will see on login.
Expose multiple drives in FTPS
Create a single root and link drives into it. Run PowerShell as Administrator.
New-Item -Path 'C:\ftproot' -ItemType Directory -Force
New-Item -ItemType SymbolicLink -Path 'C:\ftproot\C' -Target 'C:\'
New-Item -ItemType SymbolicLink -Path 'C:\ftproot\D' -Target 'D:\'
New-Item -ItemType SymbolicLink -Path 'C:\ftproot\E' -Target 'E:\'Or via CMD:
cmd /c mklink /D "C:\ftproot\C" "C:\"
cmd /c mklink /D "C:\ftproot\D" "D:\"
cmd /c mklink /D "C:\ftproot\E" "E:\"Generate TLS certificate
Option A: OpenSSL
openssl req -newkey rsa:2048 -nodes -keyout C:\ftps\ftp.key -x509 -days 365 -out C:\ftps\ftp.crtOption B: PowerShell PFX
$cert = New-SelfSignedCertificate -DnsName "your.domain.example" -CertStoreLocation "Cert:\LocalMachine\My" -KeyExportPolicy Exportable -NotAfter (Get-Date).AddYears(1)
$pwd = ConvertTo-SecureString "changeThisPass" -AsPlainText -Force
Export-PfxCertificate -Cert $cert -FilePath "C:\ftps\ftps.pfx" -Password $pwdWindows Firewall rules
New-NetFirewallRule -DisplayName "FTPS control 21" -Direction Inbound -Protocol TCP -LocalPort 21 -Action Allow
New-NetFirewallRule -DisplayName "FTPS passive 50000-50050" -Direction Inbound -Protocol TCP -LocalPort 50000-50050 -Action AllowClient settings
- Protocol: FTP
- Encryption: Require explicit FTP over TLS
- Host: your public IP or LAN IP
- Port: 21
- Transfer Mode: Passive
- Username and password from
config.json - Accept the certificate warning if self-signed
Run
node index.jsYou should see something like:
[FTPS] TLS enabled with key/cert or pfx
FTP EnabledTroubleshooting
- Plain FTP works but FTPS fails → check key/cert paths and client encryption mode.
- 502 command not supported → client using SFTP or implicit FTPS instead of explicit.
- Data connection fails → open firewall/forward passive ports, and ensure
FTPIPmatches your public IP.
