Bypass root folder and directly cd to an ftp location

Nimit Dhulekar via curl-library <[email protected]> Mon, 13 Oct 2025 16:17:42 +0000
Newsgroups gmane.comp.web.curl.library
Message-ID <BL0PR05MB6628A0CA8AF6368A0D5481C8C3EAA@BL0PR05MB6628.namprd05.prod.outlook.com>
Hi,
We're running into an issue when using libcurl (and curl). If the root folder of an FTP server denies access for security reasons and we want to directly connect to a different folder, this fails with a 550 Permission Denied. This is happening because curl is still making an initial connection to "/", and then calls cd to change to the requested folder. Here is a log snippet of what we're observing:


00000054 2025-Oct-02 07:56:53.489043 0x0000389c I     [INFO] Re-using existing connection with host 192.168.1.10
00000055 2025-Oct-02 07:56:53.489043 0x0000389c G     [HEADER OUT] CWD /
00000056 2025-Oct-02 07:56:53.494092 0x0000389c G     [HEADER IN] 550 Permission denied
00000057 2025-Oct-02 07:56:53.494092 0x0000389c I     [INFO] Server denied you to change to the given directory
00000058 2025-Oct-02 07:56:53.494092 0x0000389c I     [INFO] Connection #0 to host 192.168.1.10 left intact
00000059 2025-Oct-02 07:56:53.494092 0x0000389c R     res=9

Is there a way to make a connection directly to the requested folder without curl first connecting to the "/"? Evidently, this works when using certain Java APIs such as org.apache.commons.net.ftp.FTPClient.

Thanks,
Nimit

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html