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

使用curl通过SFTP上传文件时生成空文件但无报错的问题排查与解决求助

使用curl通过SFTP上传文件时生成空文件但无报错的问题排查与解决求助

大家好,我最近碰到一个很棘手的问题,想请各位帮忙分析排查下:

我需要用curl通过SFTP把一个文本文件上传到远程服务器,执行命令后认证顺利完成,也没有返回任何错误,但服务器上创建出来的文件却是空的。我原本期望上传的是包含内容的非空文件。

我执行的curl命令是:

curl -v -T file.txt -u username:password sftp://hostname.com

对应的详细输出如下:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying **.*.**.***...
* TCP_NODELAY set
* Connected to hostname.com (**.*.**.***) port 22 (#0)
* User: username
* completed keyboard interactive authentication
* Authentication complete
 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host hostname.com left intact

但用原生的sftp工具上传同一个文件却完全正常,服务器上的文件是有内容的:

sftp sftp://username@hostname.com:22
Connected to hostname.com.
sftp> put file.txt
Uploading file.txt to /file.txt
sftp>

我的环境信息:

  • curl版本:7.61.1
  • 操作系统:Oracle Linux Server 8.5

麻烦各位帮忙看看这可能是什么原因,以及该怎么排查解决,非常感谢!

备注:内容来源于stack exchange,提问作者Anton Yaniuk

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.21 16:12:58