问题标签 [ssh2-sftp]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - scandir/opendir 不能与 ssh2.sftp 一起使用?
如果我尝试以下命令:
它有效,我得到了正确的内容。但是每当我想拥有远程文件夹的所有文件时,都无法打开该目录。
我试过scandir或opendir。这两个都提出了这个信息:
我做错了什么?一些提示真的会帮助我。
问候
上下文:我使用 PHP 7.0.32 并且 ssh2.so 已完全安装
更新:我明白了。我认为这是由于提供者的错误态度造成的。这个怎么运作:
函数ssh2_sftp_realpath + ' ./ ' 可以解决问题。
node.js - SFTP in node downloads blank files only
I've been trying for a while now to download a file from my SFTP file storage to my local machine - And visited a number of stack posts - Like this one:
SFTP modules in Node to download and delete files
However, I cannot get it to work. I have this code - Which is exactly the same as that posted by Mscdex in the question I have linked to - But it does not work.
It does download a file to my local machine - However, this is a totally blank file. At first I thought it was due to the file format I need to download - .csv.gz - But even when testing with simple .json and .html files, it still downloads a blank file.
Can anyone shed some light onto why I'm running into this issue? My end goal is to download the file as a stream and push it to the client side browser via the response headers.
UPDATE
I have found a way to download the file, instead of using the npm module ssh2-sftp-client, I used npm module ssh2. I can download the file fine with this code:
However, Can anybody tell me how I would return a stream using this code rather than downloading the file as I want to be able to push the stream to the client and download the file in the browser.
Many thanks in advance,
G
node.js - 将 sftp ReadableStream 管道传输到文件不会终止
我正在尝试使用 sftp 服务器下载(获取)文件,即使在ReadableStream上触发事件并且在 WriteableStream 上触发ssh2-sftp-client
事件后,程序也不会终止并挂起。下面是程序及其输出。也没有错误,我该如何调试?怎么了?任何帮助将不胜感激end, close
finish and close
输出
php - PHP 使用 FWRITE 和 SSH2 上传多个文件
我正在尝试将多个文件从本地目录上传到 SFTP 站点。
我可以让它适用于单个文件,但我希望能够上传多个具有变量名称的文件。
我相信它在那里,但我无法得到最后一点正确。
非常感谢你提前
sftp - SFTP 移动文件不触发事件
我已经设置了一个 SFTP 服务器和一些我想在文件准备好时启动的触发器。
万一我在完成之前就开始了,或者如果连接出现错误,我会先写入一个tmp
文件夹(使用 SFTP 协议),然后将其复制到一个new
文件夹中。
我正在使用 inotify 跟踪一个文件夹和另一个文件夹中的所有事件:
在 tmp 文件夹中写入文件的事件是:
我注意到,如果我将文件从一个文件夹从 bash 移动到另一个文件夹:
MOVE_TO
触发了一个事件。在 tmp 文件夹中:
在新文件夹中:
但是,如果我通过 SFTP 使用 RENAME 方法移动文件,则不会。这些是所有触发的事件:
在 tmp 文件夹中:
在新文件夹中:
这是 SFTP 协议的一部分吗?是否可以在 sftp 中移动文件并实际触发 MOVED_TO 事件?
这是我正在使用的 sftp 客户端的实现: https ://github.com/mscdex/ssh2-streams/blob/55fd9c36b6dca8dbf0588a1d6f450b85c784dc72/lib/sftp.js 我正在使用 openssh-sftp-server 作为服务器
php - 当我尝试关闭 ssh2 连接时,没有回复
我编写了一个 php 脚本,在 php7.3 的 apache 服务器上本地执行,执行以下操作:
- 通过 ssh2 访问服务器
- 检查文件是否存在
- 紧密连接
- 打印 json 数据对象作为响应。
除了关闭连接之外,脚本可以正常工作。如果我添加 ssh2_disconnect 函数,则不会返回任何响应。我错过了什么?这是我的代码:
node.js - NodeJS:从 sftp 服务器读取 csv 文件并将其转换为 JSON
我正在使用 ssh2-sftp-client 读取 CSV 文件并创建 ReadableStream。然后我试图在库 csvtojson 的帮助下将此 readableStream 转换为 Json。但是,我总是收到以下错误:
TypeError:readStream.pipe 不是函数
到目前为止,这是我的代码:
有谁知道我是否正确使用了这两个库,或者我尝试实现的目标是否可行?
python - 通过 Paramiko 的 SFTPClient 的无密码连接不起作用
我有两个lxd
容器,一个master
,另一个是 a slave
。我已将 of 粘贴ssh-key
到master
of~/.ssh/authorized_keys
中slave
,这样我就可以简单地从master
到 中进行无密码登录slave
没有任何密码。
现在,我想将一些文件从's 发送master
到slave
using paramiko
's SFTPClient
。代码是:
我在我的master
节点上运行此代码,并且10.154.151.252
是slave
. ssh
请注意,我可以轻松地将这两者连接起来。
当我尝试进行无密码登录时,问题就来了。我也试过
transport.connect(username="root",password="")
了,但也没有成功。
那么,我在这里遗漏了一些明显的东西吗?
这是我生成的 paramiko 日志
/tmp/paramiko.log
:
node.js - 通过 SFTP 连接流式传输文件到客户端
我正在编写一个通过 sftp 连接到文件存储的 Node Express 服务器。我正在使用ssh2-sftp-client包。
要检索文件,它具有具有get
以下签名的功能:
dst
参数应该是字符串或a writable stream, which will be used as the destination for a stream pipe
.
我想避免在我的服务器上创建文件对象,而是将文件传输到我的客户端以节省内存消耗,如本文所述。我尝试使用以下代码来完成此操作:
但是,这会导致我的节点服务器由于未处理的承诺拒绝而崩溃。我正在尝试的可能吗?在发送到客户端之前,我应该先将文件存储在我的服务器机器上吗?我已经检查了有问题的 sftp 包的文档/示例,但找不到我正在寻找的示例。
node.js - Query a remote server's operating system
I'm writing a microservice in Node.js, that runs a particular command line operation to get a specific piece of information. The service runs on multiple server, some of them on Linux, some on Windows. I'm using ssh2-exec
to connect to the servers and execute a command, however, I need a way of determining the server's OS to run the correct command.
I have an idea for the solution: following this question, run some other command beforehand, and determine the OS from the output of said command; however, I want to learn if there's a more "formal" way of achieving this, specifically using SSH2
library.