Questions tagged [ssh2-sftp]

Request the SFTP subsystem from an already connected SSH2 server.

Request the SFTP subsystem from an already connected SSH2 server. An SSH connection link identifier, obtained from a call to ssh2_connect(). This method returns an SSH2 SFTP resource for use with all other ssh2_sftp_*() methods and the ssh2.sftp:// fopen wrapper.

Sample :

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$sftp = ssh2_sftp($connection);

$stream = fopen("ssh2.sftp://$sftp/path/to/file", 'r');
?>
125 questions
1
vote
1 answer

PHP upload multiple files using FWRITE and SSH2

I'm trying to upload multiple files to a SFTP site from a local directory. I can get it to work for a single file but I would like to be able to upload multiple files which have variables names too. $localFile_xml = "C:\xml\Race_" . $value;…
MdM
  • 81
  • 2
  • 9
1
vote
0 answers

scandir/opendir wont work with ssh2.sftp?

if i try the following command: $_content = file_get_contents("ssh2.sftp://".intval($sftp)."/Lorem-62398848890105_20190117-101229.txt"); it works and i get the correct content. But whenever I want to have all the files of the remote folder, the…
mainline
  • 41
  • 6
1
vote
0 answers

Node/Express API and sftp ECONNRESET error

I am trying to create a simple API in node that connects to a remote via sftp and lists directory contents. It only works on the first request and any following requests produces the following error. Error: read ECONNRESET at TCP.onStreamRead…
jerox
  • 31
  • 1
  • 3
1
vote
1 answer

Upload multiple files to SFTP from Node

I'm trying to upload multiple files to my SFTP server but not having any luck. I've seen this example: how do I send (put) multiple files using nodejs ssh2-sftp-client? But this does not seem a very efficient method as it opens and closes the…
GeorgeBT1902
  • 195
  • 2
  • 14
1
vote
1 answer

Angular 6 SSH2 - How can I handle errors using promises?

I'm trying to handle the error message from ssh2 using angular, I was trying to do a promise to handle it but it's not working, i'm new on it, sorry if it's too bad but I have no clue how to handle it. this is my promise const ssh = new…
User100696
  • 687
  • 4
  • 12
  • 26
1
vote
1 answer

How do I check whether remote directory exist or not on SFtp using nodejs?

I need to check whether a remote directory exists or not on sFtp connection. I am using the condition like, if (!sftp.Exists(remotePath)) I am using the library ssh2-sftp-client but it doesn't allow me to use the Exist methods because it doesn't…
vimalDev
  • 412
  • 1
  • 4
  • 25
1
vote
0 answers

Download files from SFTP server location to local machine in Node js using npm ssh2-sftp-client

I'm trying to download xml files present in SFTP server location into my local machine location. I've used npm package ssh2-sftp-client & using sftp.get function. Server file locations are kept in text file for…
N Rai
  • 11
  • 1
1
vote
1 answer

Error callback not used for chained then() with ssh2-sftp-client in node.js lambda

I'm very new to node and lambda, so I'm probably making some dumb mistakes. I've created a node.js aws lambda function which grabs a file from an s3 event. If the file is gzip it decompresses, uploads it to a sftp server, then creates and uploads a…
cninsd
  • 152
  • 3
  • 7
1
vote
1 answer

Verifying SSH host key in Tectia and WinSCP SFTP clients

I have two scripts to upload files into SFTP server: sftp2 --identity-key-file=D:\test_ssh2 -B d:\test.txt testUser@xxx.xxx.xxx.xxx open sftp://testUser@xxx.xxx.xxx.xxx -privatekey=D:\test.ppk -hostkey="ssh-rsa 1536…
king jia
  • 692
  • 8
  • 20
  • 43
1
vote
0 answers

Retrieve remote file via SSH2 works in PHP 7 but not PHP5.6

So.. this function works great in PHP7.. but I have to downscale the server to 5.6 because of some other code that doesn't work with PHP7. Once the server is scaled back to 5.6, this SSH2 function throws the Failed to open directory error. I have…
Henrik
  • 33
  • 4
1
vote
1 answer

I want to send a CTRL + C command to client how can I achieve this in NodeJS?

My Code Looks Like this var Client = require('ssh2').Client; var fs=require('fs'); var conn = new Client(); conn.on('ready', function() { console.log('Client :: ready'); conn.shell('xtail', function(err, stream) { …
1
vote
1 answer

Node Async ReadStream from SFTP connection

So I'm creating a class and ultimately want to create a method that takes a file on an SFTP server and produces a readstream that can be piped into other streams / functions. I'm most of the way there, except my readStream is acting strangely.…
AdamPat
  • 101
  • 1
  • 10
1
vote
1 answer

SFTP version mismatch - SFTP server only support versions 3

SFTP client initially sends the SSH_FXP_INIT (with version 2). Is there any reason why SFTP server does not send SSH_FXP_VERSION? Instead it is sending SSH_FXP_STATUS with info SFTP server only support versions 3 How then version negotiation is…
Mohit Singhal
  • 40
  • 2
  • 7
1
vote
1 answer

Reading larger sftp files with ssh2 sftp Node

I'm trying to use the ssh2-sftp library to read/write a file in Node. When I do an sftp.get on a larger CSV file (but not too large -- like 2 MB only) on an sftp site, and then read data on the returned stream, the call is hanging on me after the…
A B
  • 131
  • 1
  • 13
1
vote
0 answers

Add the SSH2 extension to MAMP PRO

I am trying to add the ssh2 extension to MAMP PRO without success. Any help would be appreciated! I've gone through these two tutorials, but neither successfully added ssh2. After completing the tutorials I checked my PHP info page, but found no…
Corrin
  • 11
  • 1
1 2 3
8 9