问题描述
我正在使用SFTP和非root用户的公共密钥发送文件,看起来像文件已发送,但是由于许可,我在目标文件夹上找不到它.
I am sending a file using SFTP and public key for non-root user, looks like the file is sent, but I cant find it on the target folder, maybe due to permission.
sftp> ls
sftp> put /tmp/testx
Uploading /tmp/testx to /folder1/target_folder
/tmp/testx 100% 5 0.0KB/s 00:01
sftp> get testx
Couldn't stat remote file: No such file or directory
File "/folder1/target_folder/testx" not found.
sftp> ls
sftp>
这是-vvv:
debug3: SSH_FXP_REALPATH . -> /folder1
debug3: Looking up /tmp/file_to_send
debug3: Sent message sender_host 4 T:17 I:2
debug3: Wrote 80 bytes for a total of 2653
debug3: Received stat reply T:105 I:2
debug3: Sent message SSH2_FXP_OPEN I:3 P:/folder1/target_directory/file_to_send
debug3: Wrote 112 bytes for a total of 2765
debug3: Sent message SSH2_FXP_WRITE I:4 O:0 S:6206
debug3: Wrote 6288 bytes for a total of 9053
debug3: SSH2_FXP_STATUS 0
目标目录
drw-rw-rw- 1 0 0 target_directory
如何确保文件已交付,而没有服务器访问权限?
How can I make sure the file is delivered, without server access ?
推荐答案
您所能做的就是在上载文件时检查是否没有错误.以上就是SFTP服务器为您提供的所有信息.
All you can do is to check that there are no errors, when uploading the file. That's all information the SFTP server gives you.
使用命令行OpenSSH sftp
客户端,可以检查其退出代码.
With command-line OpenSSH sftp
client, you can check its exit code.
echo "put file.txt" | sftp -b - user@host
if [ $? -eq 0 ]
then
echo "File uploaded"
else
echo "File NOT uploaded"
fi
另请参见如何在SFTP文件传输期间执行校验和以确保数据完整性?
SFTP服务器很可能不允许您下载刚刚上传的文件.
It's perfectly possible that the SFTP server does not allow you to download a file that you have just uploaded.
这种行为有两个常见原因:
There are two common reasons for such behavior:
- 公共上载"目录.这是为了防止您下载其他用户的文件.
- 有一些过程可以立即选择上载的文件进行处理.
这篇关于如何确认SFTP档案传送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!