ssh2-sftp-client | a client for SSH2 SFTP
kandi X-RAY | ssh2-sftp-client Summary
kandi X-RAY | ssh2-sftp-client Summary
an SFTP client for node.js, a wrapper around SSH2 which provides a high level convenience abstraction as well as a Promise based API. Documentation on the methods and available options in the underlying modules can be found on the SSH2 project pages. Current stable release is v7.2.2. Code has been tested against Node versions 14.18.3, 16.13.2 and 17.4.0. Node versions < 10.x are not supported.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ssh2-sftp-client
ssh2-sftp-client Key Features
ssh2-sftp-client Examples and Code Snippets
Community Discussions
Trending Discussions on ssh2-sftp-client
QUESTION
I'm trying to download files from sftp in nodejs, I created sftp using springboot I'm able to connect and do get() and put() operation using python/Winscp/ssh commands.
I'm able to connect with my SFTP server but its not downloading the file, it just create empty file in my directory with 0 KB size. I'm not sure what's wrong. It is working if I don't run this in a loop or I have only one file.
I have tried almost all the answers on stack overflow but nothing works for me.
...ANSWER
Answered 2021-Feb-23 at 16:12Did not found the solution.
The ugly solution was to downloaded the whole directory from SFTP instead of downloading file one by one.
QUESTION
I am trying to use ssh2-sftp-client
in NodeJS to send a file from an S3 bucket in AWS to my server.
I have seen many examples and I have tried them all with no success. I feel that this one is close but still is not working for me:
ANSWER
Answered 2021-Feb-05 at 18:16I figured it out. Not sure where exactly the problem was but this will successfully pull a file from S3 and then upload to SFTP server:
QUESTION
In my nodejs code I am using ssh2-sftp-client (https://github.com/theophilusx/ssh2-sftp-client) to transfer some files to a remote server :
The files in my directory are like :
...ANSWER
Answered 2021-Jan-18 at 14:48Worked with version 6.0.0 of ssh2-sftp-client
QUESTION
I have a Node API deployed to Google CloudRun and it is responsible for managing external servers (clean, new Amazon EC2 Linux VM's), including through SSH and SFTP. SSH and SFTP actually work eventually but the connections take 2-5 MINUTES to initiate. Sometimes they timeout with handshake timeout errors.
The same service running on my laptop, connecting to the same external servers, has no issues and the connections are as fast as any normal SSH connection.
The deployment on CloudRun is pretty standard. I'm running it with a service account that permits access to secrets, etc. Plenty of memory allocated.
I have a VPC Connector set up, and have routed all traffic through the VPC connector, as per the instructions here: https://cloud.google.com/run/docs/configuring/static-outbound-ip
I also tried setting UseDNS no
in the /etc/ssh/sshd_config file on the EC2 as per some suggestions online re: slow SSH logins, but that has not make a difference.
I have rebuilt and redeployed the project a few dozen times and all tests are on brand new EC2 instances.
I am attempting these connections using open source wrappers on the Node ssh2 library, node-ssh and ssh2-sftp-client.
Ideas?
...ANSWER
Answered 2020-Dec-12 at 21:23Cloud Run works only until you have a HTTP request active.
You proably don't have an active request during this on Cloud Run, as outside of the active request the CPU is throttled.
Best for this pipeline is Cloud Workflows and regular Compute Engine instances.
You can setup a Workflow to start a Compute Engine for this task, and stop once it finished doing the steps.
I am the author of article: Run shell commands and orchestrate Compute Engine VMs with Cloud Workflows it will guide you how to setup.
Executing the Workflow can be triggered by Cloud Scheduler or by HTTP ping.
QUESTION
I need to test a function that write a file from local path to remote path on an sftp machine using shh2-sftp-client library.
my own function is the following:
...ANSWER
Answered 2020-Nov-14 at 21:39I hope it will be useful to others, but I have found the solution. I always defined the mock by default, but then I invoked the mockImplementation() method on the instance of the ssh2-sftp-client library class, mocking the single functions. For each test I overwrite the return value of each function.
Here an example:
QUESTION
How do you download multiple txt files with fastGet? My code is as follows:
...ANSWER
Answered 2020-Jul-08 at 20:45There seem to be multiple issues in your code:
- The
loop
through files should be executed in the firstthen
block itself. sftp.fastGet
returns a promise, hence its anasynchronous
, operation, and executingasynchronous
operations inside aforEach
loop is not a good idea.
I would recommend updating your code with following changes:
QUESTION
I use ssh2-sftp-client to get some files. If I use sftp.end(); at the end I get this error in the console:
...ANSWER
Answered 2020-Jun-10 at 21:07What I believe is currently happening is that since you're not returning a Promise
from your second then()
, the third then()
gets resolved immediately (with a value of undefined
), which causes your connection to get terminated immediately (before your fastGet()
s have time to finish).
To fix this, you would need to explicitly return a Promise
from your second then()
that only gets resolved once all of the files have been transferred. You may also want to consider rejecting that promise if at least one of the transfers fails.
QUESTION
I'm trying to connect to a SFTP-Server and list the documents in the /ARCHIVE
Folder. Credentials are stored in a .env file. When I run this on my local machine it works and lists the documents.
ANSWER
Answered 2020-Jun-04 at 08:52The issue could be that your Lambda function does not have access to the SFTP host.
Is this SFTP server hosted outside of AWS or within your account ?
If it's hosted in the internet and not by you on AWS, you can do the following:
- Create a public VPC [Skip this if you already have a public VPC]
- Add a NAT Gateway in that public VPC [Also skip this if you already have a NAT Gateway]
- In the VPC where your Lambda function resides, add a route table which redirects traffic to the NAT Gateway by setting the destination as
0.0.0.0/0
and the target as your NAT Gateway which we created in step 2.
You can find a detailed answer on how to add internet connection to your Lambda function by visiting this AWS article: How do I give internet access to my Lambda function in a VPC?
If the SFTP server is already hosted by you in AWS, you can simply add access to it by using AWS security group.
Check this article on how to connect Lambda with another AWS service (it's using RDS but you can follow the same logic with your SFTP server): Configuring a Lambda function to access Amazon RDS in an Amazon VPC
Also, make sure you set the Lambda timeout to be long enough to allow connecting and exchange data with an external SFTP server.
QUESTION
I want to push files to a Windows EC2 and also get folders from my EC2 and store it in S3. As I have many EC2s, I wanted to automate this - I currently have a Node.js server on ECS that uses ssh2-sftp-client library. With the following piece of code I'm able to push files into it (similarly, I'm able to extract files from it and upload it to S3):
...ANSWER
Answered 2020-May-03 at 15:17One good way to automate the running of scripts on EC2 is to use SSM Run Command. If you set up each EC2 instance correctly, then it becomes a managed instance and you can trigger the running of scripts across a fleet of EC2 instances, chosen by tags, for example.
QUESTION
I'm working on a Node JS program to connect to a remote SFTP server to copy log files. I'm using this NPM package. ssh2-sftp-client
...ANSWER
Answered 2020-Mar-17 at 22:59In short, when you have a "chain" of promises (a.then(() => b.then(() =>...
) and you want to do something at the end of them, you simply add that thing to the last .then
callback.
However, if you're making multiple promises, you need to wait until all of them are finished, which you can do using Promise.all
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ssh2-sftp-client
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page