我正在创建一个脚本,将文件从 Windows 服务器上传到 SFTP 服务器。
我尝试使用 Filezilla 时一切正常。 当我尝试使用 curl 复制文件时出现权限错误
我尝试创建另一个用户(我遇到了同样的问题)并通过一个简单的密码更改密码进行测试(没有特殊字符的密码)。我仔细检查了文件夹的权限。
我已经在另一个上使用这个脚本成功地在 FTP(不是 SFTP)服务器上发送文件
在我的脚本下面:
@echo off
::#### VARIABLES####
set user_ftp=user
set pwd_ftp=password
set ip_ftp=ftp.test.com
set path_ftp=/data/TEST
::LOCAL FOLDER TO TRANSFER
set local_path="D:\Quote_pdf"
::#### CURL SOURCES####
set rep_root=C:\BATCH\FTPSite\curl
set rep_bin=C:\BATCH\FTPSite\curl\bin
set rep_log=C:\BATCH\FTPSite
::#### FILES COPY####
chdir /D %local_path%
if exist ./*.* (
FOR %%f IN (*.*) DO (
%rep_bin%\curl.exe -v --insecure -u %user_ftp%:%pwd_ftp% -Q >"+CWD %path_ftp%" -T "%%f" sftp://%ip_ftp%/
echo "%date%|%time:~0,2%h%time:~3,2% : file %%f -- sent" >>%rep_log%/log_sftp.log
)
::)
这是我的回报:
% 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 ftp.test.com:22...
* Connected to ftp.test.com (ftp.test.com) port 22 (#0)
* SSH MD5 public key: NULL
* SSH SHA256 public key: NULL
* SSH authentication methods available: publickey,gssapi-keyex,gssapi-with-mic,password
* Using SSH private key file ''
* SSH public key authentication failed: Unable to extract public key from private key file: Unable to open private key file
* Initialized password authentication
* Authentication complete
* Upload failed: Permission denied (3/-31)
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Connection #0 to host ftp.test.com left intact
curl: (9) Upload failed: Permission denied (3/-31)