You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:使用cURL的--ftp-create-dirs在SFTP连接中无法创建目录

Troubleshooting --ftp-create-dirs Not Working Over SFTP

Hey there, let’s dig into why your --ftp-create-dirs flag isn’t creating directories even though your SFTP authentication checks out (and you can browse existing files/dirs). Here are actionable steps to diagnose and fix this:

1. Confirm You’re Using the Flag with the Right Tool & Syntax

Different tools (like rsync, lftp, or curl) handle --ftp-create-dirs (or equivalent flags) differently:

  • For rsync: The --ftp-create-dirs flag only creates missing parent directories for the target file path—not empty directories on their own. You need to:
    • Include the flag before your source/target paths (order matters!)
    • Specify a target path that includes the missing directory you want to create
    • Example of a working command:
      rsync -avv --ftp-create-dirs ./local-document.pdf sftp://your-user@your-server:/existing-parent-dir/new-subdir/
      
      The -vv adds verbose output to show exactly what rsync is trying to do.
  • For lftp: Use mirror --create-dirs for directory syncs, or put --create-dirs for single files instead of the generic --ftp-create-dirs flag.

2. Verify Remote Directory Permissions

Just because you can read files doesn’t mean you have write access to the parent directory where you’re trying to create new folders:

  • Use your SFTP client to run ls -ld /path/to/parent-dir (replace with your actual parent path)
  • Check that your SFTP user has write permission (the w flag) on that parent directory. If not, you’ll need to ask the server admin to adjust permissions or assign you to the correct group.

3. Test Manual Directory Creation First

Rule out server-side restrictions by manually creating a directory via SFTP:

  • Run mkdir /path/to/parent-dir/new-test-dir directly in your SFTP session
  • If this fails, the issue is definitely a permission or server configuration problem (not the --ftp-create-dirs flag itself)
  • If this works, the problem is with how you’re using the flag in your command.

4. Check for Relative Path Gotchas

If you’re using relative paths (e.g., new-dir instead of /full/path/to/new-dir), confirm your SFTP session’s default working directory first with pwd. Your relative path will be resolved against this directory—so if you’re trying to create a folder outside this default path, you’ll need to use an absolute path.

5. Enable Verbose Logging to Spot Hidden Errors

Add verbose flags to your command to see exactly what’s failing:

  • For rsync: Add -v or -vv to get detailed logs about directory creation attempts
  • For curl (if using with SFTP): Add -v to see the full SFTP command exchange with the server
    Look for lines like "skipping directory creation" or permission denied messages—these will point you straight to the root cause.

内容的提问来源于stack exchange,提问作者YTZ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:05:37