如何确认 SFTP 文件传送? [英] How to confirm SFTP file delivery?

查看:33
本文介绍了如何确认 SFTP 文件传送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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 客户端,您可以检查其退出代码(您需要使用 -b 开关).

With command-line OpenSSH sftp client, you can check its exit code (you need to use the -b switch).

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 文件传送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆