spmjs / node-scp2 Goto Github PK
View Code? Open in Web Editor NEW[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
it might help someone. Here are the definitions I'm using for typescript.
declare module "scp2" {
interface ScpOptions {
port?: number;
host?: string;
username?: string;
password?: string;
paths?: string;
}
interface attrs {
size: number;
uid: number;
gid: number;
mode: number | string;
atime: number;
mtime: number;
}
interface writeOptions {
destination: string;
content: string;
attrs: attrs;
source: string;
}
export class Client {
constructor(options: ScpOptions);
sftp(callback: (err: string, sftp: Client) => void);
close(): void;
mkdir(dir: string, attrs: attrs, callback: (err: string) => void);
write(options: writeOptions, callback: (err: string) => void);
upload(src: string, destination: string, callback: (err: string) => void);
download(src: string, destination: string, callback: (err: string) => void);
on(eventName: string, callback: () => void);
}
export interface client {
defaults(options: ScpOptions);
scp(fileName: string, options: ScpOptions | string, errCallback?: (err: string) => void);
scp(fileName: string, options: ScpOptions | string, glob: string, errCallback?: (err: string) => void);
}
}
And now you can use it as
import { Client } from 'scp2';
let client = new Client({
port: 22
});
If there's an error such as unknown host, the callback function will be called two times.
Hey @lepture,
Thanks for this package! I really like what you've done with scp2. It has been working very well for my uses except for the one bug I keep seeing repeatedly.
Some of my SCP operations copy entire directories via SCP. During a fraction of these operations, I see the following error thrown:
/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:873
err = new Error('Underlying stream not writable');
^
RangeError: Maximum call stack size exceeded
at new Error (native)
at SFTP._send (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:873:11)
at SFTP.stat (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:627:15)
at /Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/lib/client.js:130:12
at Object.async.until (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/async/lib/async.js:647:13)
at /Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/async/lib/async.js:651:23
at /Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/lib/client.js:137:9
at SFTP._send (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:875:7)
at SFTP.stat (/Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:627:15)
at /Users/mplewis/Dropbox (Personal)/projectsync/nodejs/statichook/node_modules/scp2/lib/client.js:130:12
I've narrowed it down to scp2/lib/client.js
as follows.
Below is a visual representation of the stack overflow taken from node-debug
:
I inserted some debug lines into the subroutine inside Client.prototype.mkdir
as shown:
/* Line */
/* 130 */ sftp.stat(dir, function(err, attr) {
/* 131 */ console.log('ERR: ', err);
/* 132 */ console.log('DIR: ', dir);
/* 133 */ console.log('DIRS: ', dirs);
/* 134 */ if (err) {
/* 135 */ dirs.push(dir);
These debug lines produced the following output during program runtime:
ERR: [Error: Underlying stream not writable]
DIR: /home/public/ieee-checkin
DIRS: []
ERR: [Error: Underlying stream not writable]
DIR: /home/public
DIRS: [ '/home/public/ieee-checkin' ]
ERR: [Error: Underlying stream not writable]
DIR: /home
DIRS: [ '/home/public/ieee-checkin', '/home/public' ]
ERR: [Error: Underlying stream not writable]
DIR: /
DIRS: [ '/home/public/ieee-checkin', '/home/public', '/home' ]
ERR: [Error: Underlying stream not writable]
DIR: /
DIRS: [ '/home/public/ieee-checkin', '/home/public', '/home', '/' ]
ERR: [Error: Underlying stream not writable]
DIR: /
DIRS: [ '/home/public/ieee-checkin', '/home/public', '/home', '/', '/' ]
ERR: [Error: Underlying stream not writable]
DIR: /
DIRS: [ '/home/public/ieee-checkin', '/home/public', '/home', '/', '/', '/' ]
ERR: [Error: Underlying stream not writable]
DIR: /
DIRS: [ '/home/public/ieee-checkin', '/home/public', '/home', '/', '/', '/', '/' ]
...continues...
Once the program hit the call stack limit, it crashed.
It looks like the program is attempting to create a directory, but failing due to the Underlying stream not writable
error.
I believe you're trying to handle this error:
ERR: { [Error: No such file] type: 'NO_SUCH_FILE', lang: '' }
I think your code is seeing the Underlying stream not writable
error, catching it as if it were a NO_SUCH_FILE
error, and proceeds to assume the directory in which it's trying to mkdir
doesn't exist. Because of this, the function continues to iterate up the directory tree and continues to get that error and attempt recursion until the call stack overflows.
NO_SUCH_FILE
error. Let all other errors throw. I'm working on a patch for that for my code.Underlying stream not writable
error appears. It stems from line 892 in SFTPv3.js in the ssh2 library.Edit: New discovery!
Underlying stream not writable
appears if I call the same hook twice in a row, connecting to the same server and uploading the same files using the same password/key.
This leads me to believe that Client.prototype.close
is not being called properly and possibly that I am reusing the sftp
object in an improper way. Does any of this sound right?
I've implemented changes to scp.js
that mitigate this problem.
The changes involve making the client
object in scp.js
no longer a singleton pointing to a once-instantiated new Client()
.
Instead, Client
is imported as follows:
var Client = require('./client').Client;
and client
is set to an instance of Client
:
var client = new Client();
Then, each time scp
is called, client
is reinstantiated:
exports.scp = function(src, dest, callback) {
client = new Client();
/* ... other code ... */
};
This may be wasteful and it may trigger garbage collection more often, but it is a functional workaround that I will use for the time being.
tl;dr: using a new Client
for each scp(...)
solves this problem on my machine
My system versions are as follows:
Node 0.11.9
scp2 0.1.4
OS X 10.9.3
I'm not sure if there's any way for you to reproduce this on your machine or if you've seen this before. I'm happy to help out.
I'm connecting via SCP with password to a NearlyFreeSpeech server. I think this issue may be server-system-specific or server-SCP-version-specific. I don't think that any more—see suggestion #2.
Let me know what you think. Thanks for taking a look!
Matt
用scp2上传会报错(这时服务器其实已经创建了一个文件夹),之后用系统的scp命令会显示permission。
但是如果先用系统的scp上传,之后再用scp2上传就能成功。
Hi,
I am trying to download a file from a remote linux server (from directory /home/dataFiles/test.txt) into node server (to directory H:/dataDirOnNodeServer). In order to do so I run the following:
client.scp('linuxUsername:linuxPassword@linuxserverName:/home/dataFiles/test.txt', 'H:/dataDirOnNodeServer', function(err) {
console.log(err);
})
I get an error: Error: Underlying stream not writable
I would really appreciate it if you can help me with this.
Many Thanks.
Ana
Every write action emit an event.
This RegEx needs to be updated to include an underscore:
^([a-zA-Z0-9\-\.]+)(\:.*)?@([^:]+)(\:.*)?$
For example:
^([a-zA-Z0-9\-_\.]+)(\:.*)?@([^:]+)(\:.*)?$
This is then correctly parsed:
[email protected]:path/
Thanks for the great package!
I did not find any way to monitor file transfer progress, is it possible? Of if you give me a hint, I can implement this myself.
I'm downloading a 25mb zip file from sftp. Zip has one csv file in UTF.
scp2 downloads 25.8 MB (27,103,241 bytes) instead of 25.8 MB (27,103,654 bytes).
tried couple of times locally and remote. Any suggestions why this is happen?
Using this form:
client.scp({
host: 'example.com',
username: 'admin',
password: 'password',
path: '/home/admin/file.txt'
}, './', function(err) {})
It seems that the ssh connection is staying open. No problem when copying from the client to the server though, but I see they take two different code paths.
Not sure if there is anyway to do this currently and if so let me know.
I am looking for a way to setup a listener on the client to capture, on an interval, the progress of the file being downloaded.
Example:
client = new Scp2.Client config
client.on 'transfer', (bytes) ->
Logger.verbose "Bytes transfered (#{localFile}): #{bytes}"
client.download remoteFile, localFile, (error) ->
callback error, localFile
The only place that the 'transfer' event is currently emitted is in the Client.write method.
I made a Gist with some minor updates to Client.prototype.download
to emit this.
Any comments/thoughts?
https://gist.github.com/charlietilt/8d6c64b50ebf688b47e1
If I run SCP from the command line I can run it with the flag to preserve the local file permissions: scp -p <local> <remote>
. Is that possible with this library? If so what would be involved with adding this capability?
am using scp2 for file transfer in my Node.js program. As per the instruction on npmjs.com, I tried to do following:
var Client = require('scp2').Client;
var client = new Client({
port: 22
});
But in the above code, the program fails to instantiate Client and it complains that Client is undefined. Am I missing somthing in the document? Can you please help?
Using scp2 under Node 6 throws deprecation warnings for graceful-fs (used by glob 4.x).
fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
npm outdated
returns the following
Package Current Wanted Latest Location
async 0.9.2 0.9.2 2.0.0-rc.3 scp2
glob 4.0.6 4.0.6 7.0.3 scp2
jscoverage 0.5.9 0.5.9 0.6.0 scp2
lodash 2.4.2 2.4.2 4.11.1 scp2
ssh2 0.4.15 0.4.15 0.5.0 scp2
The latest version of glob (7.0.3 as of today) does not directly use graceful-fs anymore (although it is pulled in later down the line by a dev dependency, but as [email protected]).
The best thing to do would be to update all of the dependencies. Thoughts?
hello, I am using scp2.client to using sftp to upload the files, it uses upload function and showing correct path and its showing file uploaded successfully but when I see in ftp server the file does not uploaded.. can you please help..
Using the following type of call:
client.scp({
host: 'example.com',
username: 'admin',
password: 'password',
path: '/home/admin/file.txt'
}, './', function(err) {})
When an attempt to copy a file that doesn't exist occurs, the err
object in the callback function has a type
property of NO_SUCH_FILE
. This is great. However an empty file is still created at the target location. How do I stop this from happening?
I am uploading a pdf file to an sftp server using your module, but the process is hanging if the file already exists.
Local file is chmod to 777.
var Service,
client = require('scp2'),
Q = require('q'),
fs = require('fs');
Service = function () {};
Service.prototype.uploadFile = function (conn, settings, path) {
var deferred,
filename = path.substring(path.lastIndexOf('/') + 1);
deferred = Q.defer();
client.scp(path, {
host: settings.host,
username: settings.user,
password: settings.password,
path: settings.path
}, function (error) {
if (error) {
console.log('Error');
deferred.reject(error);
}
client.close();
console.log('Callback called.');
deferred.resolve(path);
});
return deferred.promise;
};
module.exports = Service;
Is this a known issue? I'm fairly certain i'm using the module as intended.
Does not work:
scp2 out/*.* u:p@server:dest/
works:
scp2 out/index.html u:p@server:dest/
Hello:
node-scp2
is a good tool to upload or download file from remote. When I use client.scp
method in node-webkit
, I meet a problem: first time the code run perfectly, but when I click the upload button to run this code again, it throw an exception. It refuse me. After I look over the scp2 source code, I found this in scp.js
file:
async.eachSeries(files, function(fpath, done) {
fs.stat(fpath, function(err, stats) {
if (err) {
done(err);
return;
}
if (stats.isFile()) {
var fname = path.relative(rootdir, fpath);
client.upload(
fpath, path.join(client.remote.path, fname), done
);
} else {
done();
}
});
}, function(err) {
// never forget to close the session close by myself
client.on('close', function() {
callback(err);
});
client.close();
});
This problem is because that after client.scp
method, it close the connection automatically, so next time when I run this method, the code throw an error!
I suggest that whether client.scp
method can add a parameter like autoclose: false?? so user can choose whether the connection should be closed or not.
Thanks!!
When I try to write a file with contents as given in example, it comes back with error:
C:\ .... node_modules\scp2\lib\client.js:228
throw new Error('Content should be buffer or file descriptor');
My code
createFileOnScriptEnginer = function(contents,destinationPath){
var Client = require('scp2').Client;
var cl = new Client({
port: 22,
host: "10.xxx.xxx.131",
username: "root",
privateKey: require('fs').readFileSync("server/components/ssh/ssh_key"),
});
cl.write({
destination: destinationPath,
content: contents
}, function(err){
})
};
createFileOnScriptEnginer('sdfdddddddddsfd','/tmp/testfile.txt');
And the I tried to create Buffer like below. And this time it creates the file but program hangs.
exports.createFileOnScriptEnginer = function(contents,destinationPath){
var Client = require('scp2').Client;
var buffer = new Buffer(contents, "utf-8")
var cl = new Client({
port: 22,
host: "10.xxx.xxx.131",
username: "root",
privateKey: require('fs').readFileSync("server/components/ssh/ssh_key"),
});
cl.write({
destination: destinationPath,
content: buffer
}, function(err){
})
};
Downloading any type of files works great, unless their size is over 65536 bytes.
For files over 65k, it looks like the download went well (no err in the callback) but they get corrupted after the first 65536 bytes. I can attach an example of a file before and after if needed.
I also tried over an external network, as well as a local network (guest + vm) but the issue remains.
I may be missing some special configuration for larger files?
Here is the testing code I'm using:
var client = require('scp2');
client.scp({
host: 'the-remote-host',
username: 'the-remote-username',
password: 'the-remote-password',
path: path.join('/tmp', 'file.tar')
}, path.join(process.cwd(), 'file.tar'), function (err) {
if (err) {
console.log('Unable to get the file back! ');
client.close();
} else {
console.log('File downloaded successfully');
client.close();
}
});
Let me know if I can do anything else to help...
Thanks!
I am running into an issue that has already been resolved in ssh2: mscdex/ssh2#263
However, since scp2 package.json uses an old version of ssh2, this issue is not yet fixed. I can work around this by manully updating the ssh2 version used by scp2, but it would be nice to be able to npm install and have it work out of the box.
Current version of ssh2 at the time of this writing is 0.4.10.
Thanks!
What I'm trying to do is to SCP a directory using a privatekey.
I can configure the low-level Client with the key, but then I can't upload directories.
If I try to use the high-level scp method which states directory support, it doesn't seem to let me add a privatekey anywhere.
The module crash the application when copying file to a machine without sftp, even when called with yield inside try-catch statement or with listening to scp.on('error', cb):
Error: Unable to start subsystem: sftp
at /.../node_modules/scp2/node_modules/ssh2/lib/client.js:1283:19
at SSH2Stream.<anonymous> (/.../node_modules/scp2/node_modules/ssh2/lib/Channel.js:185:24)
at emitNone (events.js:86:13)
at SSH2Stream.emit (events.js:185:7)
at parsePacket (/.../node_modules/scp2/node_modules/ssh2-streams/lib/ssh.js:3225:10)
at SSH2Stream._transform (/.../node_modules/scp2/node_modules/ssh2-streams/lib/ssh.js:551:13)
at SSH2Stream.Transform._read (_stream_transform.js:167:10)
at SSH2Stream._read (/.../node_modules/scp2/node_modules/ssh2-streams/lib/ssh.js:212:15)
at SSH2Stream.Transform._write (_stream_transform.js:155:12)
at doWrite (_stream_writable.js:307:12)
at writeOrBuffer (_stream_writable.js:293:5)
at SSH2Stream.Writable.write (_stream_writable.js:220:11)
at Socket.ondata (_stream_readable.js:555:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:172:18)
noticed that the public api has been changed from 0.2.0 to 0.2.1, this is terrible while lots of people may install this module and use '~' to indicate the version, it's better to change to min version if any public api was changed
I am attempting to copy a directory remotely using SSH and public-key method. It will work once, and then I get this on the next attempt to upload.
Error: write after end
at writeAfterEnd (_stream_writable.js:132:12)
at ChannelStream.Writable.write (_stream_writable.js:180:5)
at SFTP._send (/usr/local/app/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:1017:23)
at SFTP.stat (/usr/local/app/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:750:15)
at /usr/local/app/node_modules/scp2/lib/client.js:134:12
at Object.async.until (/usr/local/app/node_modules/async/lib/async.js:707:13)
at /usr/local/app/node_modules/scp2/lib/client.js:130:11
at Client.sftp (/usr/local/app/node_modules/scp2/lib/client.js:50:5)
at Client.mkdir (/usr/local/app/node_modules/scp2/lib/client.js:119:8)
at /usr/local/app/node_modules/scp2/lib/client.js:257:14
The app then restarts and I'm able to make the request once again. It seems like one of the streams being used isn't being closed correctly or isn't be recreated when the scp call is made again?
If the second parameter of .scp, the destination, is invalid it throws an undescriptive (IMHO) error message "handle is not a Buffer".
Example:
client.scp('file.txt', 'admin:[email protected]:/home/blah/', function(err) {...})
...where "/home/blah" doesn't exist.
In client.js at the end of Client.prototype.write() is:
sftp.open(destination, 'w', attrs, function(err, handle) {
_write(handle);
});
I'm interpreting that the code at this point has already decided that the destination isn't absolute so it assumes that its relative, prepends a path, but after calling sftp.open() again it doesn't check the return value of err before calling _write().
The solution could be to check the value of err and act accordingly:
sftp.open(destination, 'w', attrs, function(err, handle) {
if (err)
throw new Error('Destination is invalid');
_write(handle);
});
running the command scp2 -p 1234 localfile server
throws:
{ [Error: connect ECONNREFUSED SERVER-IP]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: 'SERVER-IP',
port: 22,
level: 'client-socket' }
notice that the port on the error is still 22 and not 1234 as specified
Unable to get a copy from client to server working. Getting:
Message:
Argument must be a string
Details:
domain: [object Object]
domainThrown: true
Stack:
TypeError: Argument must be a string
at Connection._authNone (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Connection.js:1336:24)
at onSERVICE_ACCEPT (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Connection.js:2412:12)
at Parser.<anonymous> (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Connection.js:133:5)
at Parser.emit (events.js:95:17)
at Parser.parsePacket (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Parser.js:474:12)
at Parser.execute (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Parser.js:249:14)
at Socket.<anonymous> (/home/brendanjerwin/projects/asset-server/services/asset-server/node_modules/scp2/node_modules/ssh2/lib/Connection.js:536:18)
at Socket.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:765:14)
at Socket.emit (events.js:92:17)
Calling it like this:
scpClient.scp(assetSourcePath, sshOptions, function (err) {
if (err) {
trace('Error while scp: %s', err);
} else {
trace('Copy completed.');
}
});
Where sshOptions
looks something like this:
{ host: 'localhost', path: '/tmp/asset_build.QCvR' }
Tried downloading a 30,000 row csv file and it only gave me the first 423 rows.
I like the way it's supposed to function, but it's obviously not useful if it's returning partial files. Not seeing any errors even.
17 Oct 17:43:43 - connected
17 Oct 17:43:43 - ready
17 Oct 17:43:44 - read /tmp/xxxxxx.csv
17 Oct 17:43:44 - scp success
Hope you get it fixed, i'd love to use this module.
Source
OS: Windows 7
Pattern: C:\Users\aaa\bbb\ccc*
Destination
OS: Linux
Folder: /home/target/out/
Expected Result
Everything in source folder C:\Users\aaa\bbb\ccc should be copied into destination directory /home/target/out/ (which already exists when scp is called)
Actual Result
Only the first file from the source folder is copied to the correct destination folder. All other files are copied to the PARENT folder of the destination folder instead, i.e. to /home/target/ instead of /home/target/out/
Sample Code
function run(srcFolder, dstConfig, cb) {
var src = path.join(srcFolder, "*");
// the following shows C:\Users\aaa\bbb\ccc\*
console.log("source pattern: " + src);
// the following shows /home/target/out/
console.log("destination folder: " + dstConfig.path);
scp(src, dstConfig, function(err) {
cb(err);
});
}
i want to use scp method to copy a directory to the remote host,but it cost too much time to finish it. but i use scp command directly, it cost very little time , i don't know why.
After some trials of not getting the privateKey to work, we finally found that we need to initialize this library using:
var scp = require('scp2');
var client = new scp.Client({
host : config.sshHost
port : config.sshPort,
username : config.sshUser,
privateKey : config.sshPrivatekey
});
This was rather unclear in the documentation and is recommended to be updated.
Hey @spmjs thanks for the awesome libray!
I'm unable to close the connection. I have a really simple example like this. No errors occur and the process never exists. Any help would be amazing.
import scpClient from 'scp2'
scpClient.scp(source, dest, function(err) {
if (err) {
scpClient.close()
return reject(err)
} else {
scpClient.close()
return resolve()
}
})
https://github.com/lepture/node-scp2/blob/master/lib/client.js#L281
Error is never checked, and instead assumes sftp will always be defined. In cases where an error has occurred, a TypeError: Cannot call method 'createReadStream' of undefined
is thrown
(node) warning: possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit.
please help me
看了一下服务器,文件是可以正常上传的,但出现一个没有catch的error如下:
fs.js:457
binding.read(fd, buffer, offset, length, position, wrapper);
^
Error: Offset is out of bounds
at Object.fs.read (fs.js:457:11)
at /Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:192:14
at iterate (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/async/lib/async.js:131:13)
at Object.async.eachSeries (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/async/lib/async.js:147:9)
at _write (/Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:189:15)
at /Library/WebServer/Documents/coder/node_modules/scp2/lib/client.js:221:11
at SFTP._parse (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:978:11)
at ChannelStream.<anonymous> (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:49:12)
at ChannelStream.EventEmitter.emit [as _emit] (events.js:95:17)
at ChannelStream.emit (/Library/WebServer/Documents/coder/node_modules/scp2/node_modules/ssh2/lib/Channel.js:547:12)
node version: v0.10.12
npm version: 1.2.32
scp2: lastest
does it support resume transfer?
a
时,disabled 属性不生效。This repo is not maintained well. I have too many organizations and too many projects, I can't spare much time in this project any more.
Anyone (one or more) wants to maintain this repo?
My ~/.ssh/config specifies the user when doing scp host:file
-- this module appears to ignore that.
[14:41:42] 'js:upload' errored after 10 s
[14:41:42] Error: Timed out while waiting for handshake
at [object Object]._onTimeout (/home/adones/Projects/chaipcr/node_modules/scp2/node_modules/ssh2/lib/Connection.js:232:17)
at Timer.listOnTimeout (timers.js:119:15)
EISDIR: illegal operation on a directory
I've noticed that when I use scp2 to copy an entire directory, then all hidden file (.something) that are in subfolder are not copied.
See for example https://travis-ci.org/whatwg/streams/builds/43789094#L1383
compared to https://travis-ci.org/whatwg/streams/builds/39141547#L863 with 0.1.4
(Also I might suck at shell scripting but I can't my Travis builds to fail when ssh2 throws an error :-/turns out I need to use Travis's script
hook instead of after_success
)
Use fs.read a file descriptor instead of fs.readFile.
In the commit on January 31, added export customer d069d91, but after this version has not changed. Accordingly, here is a code causes an error:
var Client = require('scp2').Client;
var client = new Client({
port: 22
});
Hi!
I'm currently having a bit of trouble concerning my upload function :
client.on('error', function(err) {
return res.status(500).json({
message: 'Error when sending image to media server',
error: err
});
});
client.upload(req.file.path, '/home2/myhome/'+image.storedName, function (err) {
if (err) {
return res.status(500).json({
message: 'Error when sending image to media server',
error: err
});
}
image.fullUrl = config.mediaURL + image.storedName;
image.save(function (err, image) {
if (err) {
return res.status(500).json({
message: 'Error when saving image',
error: err
});
}
return res.status(201).send();
});
});
If the destination file is incorrect or my permissions are wrong I get this error :
/Users/Nicolas/Documents/Davidson/Adeo/Mobility/feedback-product/node_modules/ssh2-streams/lib/sftp.js:878 throw new Error('handle is not a Buffer');
Am I missing something, or is ssh2-streams not managing the error correctly ? (As far as I know you're not supposed to throw errors in async functions in NodeJs, only return them)
If client
is not listening to the error event when authenticating with bad credentials an uncaughtException will be thrown which is hard to try/catch and will crash your app instead of giving the error in the callback.
var scp = require('scp2');
var client = new scp.Client({
port: 22,
host: 'localhost',
username: 'test',
password: 'pass'
});
//client.on('error', function(err) {
// console.log('got event error', err)
//})
client.upload('/tmp/wat.tmp', '/srv/www/wat.tmp', function(err) {
console.log('got err', err)
});
Uncommenting the listener in the code above will cause the callback to pass the err however this should be fixed or better documented in the README.
I handle my err logic in the callback so the fix for me is to add a client.on('error', function(){})
somewhere
In my company, port 22 is locked down because of security reasons. Is it possible to use port 115 or port 20 to copy files to remote server using this module?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.