gtg092x / gulp-sftp Goto Github PK
View Code? Open in Web Editor NEWGulp SFTP Deploy
Gulp SFTP Deploy
gulp-sftp
requires the size of all uploaded files to be known, otherwise it crashes on this line: https://github.com/gtg092x/gulp-sftp/blob/master/index.js#L272. Since Gulp is supposed to be the streaming build system, and gulp-sftp
is only using the size for logging (it seems), I would suggest removing the requirement. For example, gulp-sftp
could only print the progress in percentage if the size is known.
My use case is zipping a folder and uploading it immediately without writing it to the local file system.
I'm willing to make a PR but I would first like a sign from @gtg092x.
[12:37:56] Using gulpfile ~/Documents/Development/fruity-dashboard/gulpfile.js
[12:37:56] Starting 'push'...
[12:37:56] Authenticating with password.
[12:38:04] SFTP error or directory exists: Error: Failure /var/www
[12:38:04] gulp-sftp: Uploaded: apple-touch-icon-120x120.png => /var/www/apple-touch-icon-120x120.png
[12:38:04] gulp-sftp: Uploaded: apple-touch-icon-60x60.png => /var/www/apple-touch-icon-60x60.png
[12:38:04] gulp-sftp: Uploaded: apple-touch-icon-76x76.png => /var/www/apple-touch-icon-76x76.png
[12:38:04] gulp-sftp: Uploaded: favicon.png => /var/www/favicon.png
[12:38:04] gulp-sftp: Uploaded: index.html => /var/www/index.html
[12:38:04] gulp-sftp: 5 files uploaded successfully
[12:38:04] SFTP :: SFTP session closed
[12:38:04] Finished 'push' after 7.59 s
[12:38:04] Connection :: end
[12:38:04] Connection :: close with error
See line 4. Im trying to push to my server but since /var/www already exist I can't overwrite it.
Hi, when using the following settings:
gulp.task('sftp', function () {
return gulp.src(['./**/*.{css,js,gif,png}', '!./src/**/*'])
.pipe(sftp({
host: 'ftpweb.xxxx.ac.uk',
auth: 'keyMain',
remotePath: 'public_html'
}));
});
I'm finding when gulp-sftp
comes to create directories that it fails. This is what I see on my web server:
The dist
dir should be created within the public_html
dir and the styles
dir within the dist
.
I saw a recent fix (#2) for slashes but perhaps this fix needs to be extended?
A common feature of FTP clients (and other plugins such as vinyl-ftp) is the ability to only upload files that are newer than the remote or have a different size from remote.
Could this be added? It seems a waste to upload all files, and selecting only new files with gulp.src()
is often not possible.
Hi guys,
This gulp plugin have a critical issue, because after to upload files, the remote file structure is different to local (source structure).
See the current configuration
var paths = [
"./models/**",
"./public/**",
"./routes/**"
];
gulp.task('deploy', function(done) {
gulp.src(paths)
.pipe(sftp({...}))
.on('end', done);
});
But in remote doesn't exist the _models, _public and _routes_ folders. The contents of those folders is placed in the root :/
Thanks, Nicholls
Hi guys,
I am on Mac OS X El Capitan and my gulp-sftp fails with the following message:
[16:35:58] Error in plugin 'gulp-sftp'
Message:
All configured authentication methods failed
Details:
level: client-authentication
I dug a bit and this might be the cause of the error:
mscdex/ssh2#238
Can't seem to only upload the file that has changed after CSS minification.
e.g.
var gulp = require('gulp'),
changed = require('gulp-changed'),
minifycss = require('gulp-minify-css'),
sftp = require('gulp-sftp')
;
var src = './src/',
dist = './dist/';
var srcStyles = src + '**/*.css',
distStyles = dist + '**/*.css';
var host = 'ftp.xxxx.xx.xx',
auth = 'keyMain',
remotePath = 'public_html';
gulp.task('compilecss', function(){
gulp.src(srcStyles)
.pipe(changed(dist))
.pipe(minifycss({keepBreaks: true}))
.pipe(gulp.dest(dist))
;
});
gulp.task('uploadcss', function(){
gulp.src(distStyles)
.pipe(changed(dist))
.pipe(sftp({
host: host,
auth: auth,
remotePath: remotePath
}))
;
});
gulp.task('main', function(){
gulp.start('compilecss');
});
gulp.task('watch', function(){
gulp.watch(srcStyles, ['compilecss']);
gulp.watch(distStyles, ['uploadcss']);
});
gulp.task('default', ['main', 'watch']);
When files are uploading, instead of doing:
[gulp] gulp-sftp: Uploaded: gulp\dist\scripts\jquery.waypoints.js => public_html/dist/scripts/jquery.waypoints.js
it's doing (missing out parent dist
folder on transfer)
[gulp] gulp-sftp: Uploaded: gulp\dist\scripts\jquery.waypoints.js => public_html/scripts/jquery.waypoints.js
Is there a way to fix this?
Here is my code
var gulp = require('gulp');
var clean = require('gulp-clean'),
plumber = require('gulp-plumber'),
changed = require('gulp-changed'),
urladjuster = require('gulp-css-url-adjuster'),
minifycss = require('gulp-minify-css'),
uglifyjs = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
soften = require('gulp-soften'),
sftp = require('gulp-sftp'),
gutil = require('gulp-util')
;
var htmlPhpFiles = './**/*.{html,php}';
var src = './src/',
dist = './dist/';
var srcStyles = src + '**/*.css',
srcScripts = src + '**/*.js',
srcImages = src + '**/*.{gif,png}';
var distStyles = dist + '**/*.css',
distScripts = dist + '**/*.js',
distImages = dist + '**/*.{gif,png}';
var projectBase = 'gulp';
var host = 'ftp.xxxx.xx.xx',
auth = 'privateKeyCustom',
remotePath = 'public_html';
var ignoredDirs = '{secure,src}';
/*------------------------------------------------*/
var onError = function(error){
gutil.beep();
console.log(error);
};
/*------------------------------------------------*/
gulp.task('cleancss', function(){
return gulp.src([dist + '**/*.css'], {read: false})
.pipe(clean())
;
});
gulp.task('cleanjs', function(){
return gulp.src([dist + '**/*.js'], {read: false})
.pipe(clean())
;
});
gulp.task('cleanimages', function(){
return gulp.src([dist + '**/*.{gif,png}'], {read: false})
.pipe(clean())
;
});
gulp.task('compilecssremote', function(){
return gulp.src(srcStyles)
.pipe(plumber({
errorHandler: onError
}))
.pipe(changed(dist)) //must be dist
.pipe(urladjuster({
prepend: '/' + project + '/dist/' //based on location of CSS files
}))
.pipe(minifycss({keepBreaks: true}))
.pipe(gulp.dest(dist))
.pipe(sftp({
host: host,
auth: auth,
remotePath: remotePath
}))
;
});
gulp.task('compilejsremote', function(){
return gulp.src(srcScripts)
.pipe(plumber({
errorHandler: onError
}))
.pipe(changed(dist)) //must be dist
.pipe(uglifyjs({outSourceMap: false}))
.pipe(gulp.dest(dist))
.pipe(sftp({
host: host,
auth: auth,
remotePath: remotePath
}))
;
});
gulp.task('tabsto4spaces', function(){
return gulp.src(htmlPhpFiles)
.pipe(soften(4)) //4 spaces
.pipe(gulp.dest('./'))
;
})
gulp.task('optimages', function(){
return gulp.src(srcImages)
.pipe(imagemin({optimizationLevel: 5}))
.pipe(gulp.dest(dist))
;
});
gulp.task('moveotherfiles', function(){
return gulp.src(['./src/**/*', '!./src/**/*.{css,js,gif,png}'])
.pipe(gulp.dest(dist))
;
});
gulp.task('sftp', function(){
return gulp.src(['./**/*.{css,js,gif,png,php,eot,svg,ttf,woff}', '!./' + ignoredDirs + '/**/*', '!./gulpfile.js'])
.pipe(plumber({
errorHandler: onError
}))
.pipe(sftp({
host: host,
auth: auth,
remotePath: remotePath
}))
;
});
gulp.task('mainremote', function(){
return gulp.start('tabsto4spaces', 'cleancss', 'cleanjs', 'compilecssremote', 'compilejsremote', 'optimages', 'moveotherfiles');
});
/*------------------------------------------------*/
gulp.task('default', ['mainremote', 'sftp']);
I have a watch and on file change compile as necessary then upload. After the upload completes the connection is closed. Looking to be able to configure keepaliveInterval so the connection isn't closed every time in this use case.
events.js:72
throw er; // Unhandled 'error' event
^
Error: No such file
Thanks
8 pull requests waiting, 26 issues with little activity and no major code updates in over a year!
If the author needs support managing the project how about giving a few more people access to the repo?
Gulp-sftp seems to not upload empty directories (I'm uploading cache/
and uploads/
folders).
gulp.task('compile:js:remote', function(){
return gulp.src(srcJs, {base: src})
.pipe(plumber({
errorHandler: onError
}))
.pipe(removelogs())
.pipe(uglify({outSourceMap: false}))
.pipe(order([
'**/**/jquery.js',
'**/**/jquery.ui.js',
'**/**/custom.js',
'**/**/modernizr.js',
'**/**/jquery.fancybox.js',
'**/**/*.js'
]))
.pipe(concat('all.min.js'))
.pipe(gulp.dest(distScripts))
.pipe(sftp({
host: host,
auth: auth,
remotePath: remotePath + '/' + distScripts
}))
;
});
compile:js:remote
is triggered after a change (gulp.watch
) is made to source JavaScript. It should re-minify my code and upload the resulting file. However, gulp-sftp
is erroring out with the following. Only just introduced gulp-concat
to this task but previously gulp-sftp
was working without issue when I wasn't combining my JavaScript files. I've tried {buffer: false}
but on the first run where files for this project (43 files) are uploaded gulp-sftp
has no problem dealing with all.min.js
(which is only 459KB).
[14:17:33] Starting 'compile:js:remote'...
[14:17:37] Authenticating with private key.
[14:17:37] SFTP :: SFTP session closed
events.js:72
throw er; // Unhandled 'error' event
^
Error in plugin '←[36mgulp-sftp←[39m'
SFTP abrupt closure
at SFTP.<anonymous> (C:\Users\com265\AppData\Roaming\npm\node_modules\gulp-s
ftp\index.js:148:44)
at SFTP.emit (events.js:92:17)
at ChannelStream.<anonymous> (C:\Users\com265\AppData\Roaming\npm\node_modul
es\gulp-sftp\node_modules\ssh2\lib\SFTP\SFTPv3.js:58:10)
at ChannelStream.g (events.js:180:16)
at ChannelStream.emit [as _emit] (events.js:117:20)
at ChannelStream.emit (C:\Users\com265\AppData\Roaming\npm\node_modules\gulp
-sftp\node_modules\ssh2\lib\Channel.js:638:12)
at Parser.<anonymous> (C:\Users\com265\AppData\Roaming\npm\node_modules\gulp
-sftp\node_modules\ssh2\lib\Channel.js:60:20)
at Parser.g (events.js:180:16)
at Parser.emit (events.js:92:17)
at Parser.parsePacket (C:\Users\com265\AppData\Roaming\npm\node_modules\gulp
-sftp\node_modules\ssh2\lib\Parser.js:644:12)
Do you plant to support instead of username and password use ssh key?
I can not upload the fold to my server.
It shows:
" No files uploaded "
I am seeing the below error when I try to connect using the default private key (~/.ssh/id_rsa) with a passphrase. Any help or guidance would be much appreciated.
var gulp = require('gulp');
var sftp = require('gulp-sftp');
gulp.task('upload', function () {
return (
gulp.src('./www/*')
.pipe(sftp({
host: <-- host here -->,
remotePath: 'www',
passphrase: <-- passphrase here -->,
user: 'root'
}))
);
});
Error: Unable to parse private key while generating public key (expected sequence)
at Connection.connect (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/ssh2/lib/Connection.js:524:15)
at Transform.pool (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/gulp-sftp/index.js:192:11)
at Transform._transform (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/gulp-sftp/index.js:210:14)
at Transform._read (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/gulp-sftp/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at Transform._write (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/gulp-sftp/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/gulp-sftp/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/gulp-sftp/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Transform.Writable.write (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/gulp-sftp/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at write (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/Users/josiahbrower/Documents/work/unibrowdev/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:632:7)
Folders wich do not exist remtely can´t be created.
the issue is only one file gets uploaded. I have 2 files and multple folders that do NOT get transferred.
There seems to be an issue with this.
Thoughts?
return gulp.src('g:/Code/Memberships/sechubMembers/build/*')
.pipe(sftp(options))
.on('finish',function(){
util.log('sftp done');
});
Can gulp-sftp create a directory if it doesn't exist on the remote? For some reason, when I run my code, the code breaks with the following error if the directory is not already existing on remote:
events.js:72
throw er; // Unhandled 'error' event
^
Error: No such file
Hi there, thanks for your effort!
it would be amazing if you could introduce an option to only overwrite newer files, like in vinyl-ftp.
I am using gulp-sftp
to deploy website changes. It functions as a post-merge
git hook.
So, changes to the website are committed and pushed to our git repo. Then for deployment, a server runs git pull
to grab all the changes and then they are run thru gulp.
It's pretty simple right now: the changed files are separated with gulp-changed
and moved to a "build" directory and then uploaded with gulp-sftp
.
My deployment task looks like this:
gulp.task('deploy', function() {
return gulp.src(src)
.pipe(changed(dest))
.pipe(gulp.dest(dest))
.pipe(sftp({
host: 'ftp.example.com',
user: 'username',
pass: 'password',
remotePath: '/htdocs/'
}));
});
This works just fine; however, the gulp deployment task is throwing a lot of errors because it is apparently trying to create the directories that the changed files are in. It can become a bit confusing to parse out the real output to confirm that changes were deployed properly, because of all the noise from directory errors, especially with deeply nested directories.
Here is an example of the output I am seeing:
[11:53:19] Using gulpfile /foo/bar/gulpfile.js
[11:53:19] Starting 'deploy'...
[11:53:20] Authenticating with password.
[11:53:21] SFTP error or directory exists: Error: File already exists. /htdocs/Foo
[11:53:21] SFTP error or directory exists: Error: File already exists. /htdocs/Foo/Bar
[11:53:22] gulp-sftp: Uploaded: Foo/Bar/example.html => Foo/Bar/example.html
[11:54:11] gulp-sftp: 1 file uploaded successfully
[11:54:11] SFTP :: SFTP session closed
[11:54:11] Finished 'deploy' after 52 s
[11:54:11] Connection :: end
[11:54:11] Connection :: close with error
Is there an option or configuration that I have overlooked? Or is this problem related to the way I am using gulp-changed
and I should be talking to that group?
I am having issues with nested folders being created on the server. It doesn't seem to like remotePath: '/assets/img'
it will however do `remotePath: '/assets/``
My config
.pipe(plugins.sftp(
{
host: '-----',
user: 'r-----',
pass: '---',
remotePath: '/assets/img'
}
))
[16:22:54] Starting 'images'...
[16:22:56] Finished 'images' after 1.85 s
[16:22:56] Authenticating with password.
[16:22:56] gulp-imagemin: Minified 12 images (saved 36.01 kB - 15.7%)
[16:22:57] SFTP error or directory exists: Error: No such file /assets/img
events.js:72
throw er; // Unhandled 'error' event
^
Error: No such file
at SFTPStream._transform (c:\dev\crystal\Jello\node_modules\gulp-sftp\node_modules\ssh2\node_modules\ssh2-streams\lib\sftp.js:354:27)
at SFTPStream.Transform._read [as __read] (_stream_transform.js:179:10)
at SFTPStream._read (c:\dev\crystal\Jello\node_modules\gulp-sftp\node_modules\ssh2\node_modules\ssh2-streams\lib\sftp.js:160:15)
at SFTPStream.Transform._write (_stream_transform.js:167:12)
at doWrite (_stream_writable.js:223:10)
at writeOrBuffer (_stream_writable.js:213:5)
at SFTPStream.Writable.write (_stream_writable.js:180:11)
at write (_stream_readable.js:583:24)
at flow (_stream_readable.js:592:7)
at Channel.pipeOnReadable (_stream_readable.js:624:5)
Hi guys,
Is possible to execute remote commands? it would be very useful
Regards, Nicholls
I need to upload a file to a server, but this server only can download file from a sftp server. First I should upload files to the sftp server, then download file from sftp server to my target server.
What can I do?
npm list ssh2
[email protected] /Users/breogangf/Workspace/project
└─┬ [email protected]
└── [email protected]
Hi guys,
I am on Mac OS X 10.11.1 and my gulp-sftp fails with the following message:
14:43:35] 'publish' errored after 352 ms
[14:43:35] Error in plugin 'gulp-sftp'
Message:
Disconnected by host (PROTOCOL_ERROR): Packet integrity error.
Details:
level: connection-ssh
description: Packet integrity error.
lang:
[14:43:35] Connection :: end
[14:43:35] gulp-sftp SFTP abrupt closure
[14:43:35] Connection :: close
I am doing a normal publish task to our NAS
gulp.task('publish', ['zip'], function () {
return gulp.src('./build/' + zipBaseName + '*' + zipExtension)
.pipe(sftp({
host: MY_NAS_IP,
remotePath: MY_REMOTE_PATH,
auth: NAS_AUTH
}));
});
Is there a way to say "don't echo every time a file uploads?" It's mainly just distracting for me. It'd be more useful if I could say "echo only if there's an error."
My configuration, for example
gulp.task('ftp', function () {
return gulp.src(allFiles, { base: './' })
.pipe(sftp({
host: 'example.com',
port: '22',
user: 'user',
pass: 'password',
remotePath: '/remote/'
}));
});
Throws the following:
[17:50:43] SFTP error or directory exists: Error: No such file /remote/sub/folder
events.js:72
throw er; // Unhandled 'error' event
^
Error: No such file
at SFTP._parse (D:\path\to\node_modules\gulp-sftp\node_modules\ssh2\lib\SFTP\SFTPv3.js:1090:23)
at ChannelStream. (D:\path\to\node_modules\gulp-sftp\node_modules\ssh2\lib\SFTP\SFTPv3.js:72:10)
at ChannelStream.EventEmitter.emit (events.js:95:17)
at ChannelStream. (stream_readable.js:745:14)
at ChannelStream.EventEmitter.emit (events.js:92:17)
at emitReadable (_stream_readable.js:407:10)
at emitReadable (_stream_readable.js:403:5)
at readableAddChunk (_stream_readable.js:165:9)
at ChannelStream.Readable.push (_stream_readable.js:127:10)
at Parser. (D:\path\to\node_modules\gulp-sftp\node_modules\ssh2\lib\Channel.js:102:25)
Hi I have a problem with connection
Got always this kind of issue:
Authenticating with private key.
events.js:160
throw er; // Unhandled 'error' event
Error: No such file
at SFTP._parse (/node_modules/ssh2/lib/SFTP/SFTPv3.js:1090:23)
at ChannelStream.<anonymous> (/node_modules/ssh2/lib/SFTP/SFTPv3.js:72:10)
at emitOne (events.js:96:13)
at ChannelStream.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at ChannelStream.Readable.push (_stream_readable.js:134:10)
Any idea what is wrong with that. I use SFTP on Transmit app and working fine. Keys are working well via terminal SSH conection.
Can this be integrated into the library (either using sftp directory) or wrapping an own layer around it which opens multiple instances?
Uploads tend to be super slow...in comparison to i.e. Rsync (which is only allowed if complete SSH access is enabled)
I'm using 0.1.4 and getting the error below. It fails at seemingly random times and has never completed a full upload
[15:07:26] gulp-sftp: 558 files uploaded successfully
[15:07:26] Finished 'sftp' after 24 s
[15:07:26] Starting 'publish'...
[15:07:26] Finished 'publish' after 8.59 μs
[15:07:26] SFTP :: SFTP session closed
[15:07:26] Connection :: end
[15:07:26] Connection :: close with error
$
I am using pem to create private keys and certificates for this plugin.
Such as:
var pem = require('pem');
gulp.task('deploy_test', function(cb) {
pem.createCertificate({}, function (e, r) {
return gulp.src(distPath+'*')
.pipe(sftp({
host: '172.28.2.33',
port: 22,
user: 'myname',
pass: 'mypass',
secure: true,
key: r.clientKey,
cert: r.certificate,
}));
});
});
Can it be possible?
I might be missing something, but is there a way of creating a callback function that fires once the transfer is complete?
My usecase is that I was hoping to build SASS, minify, upload via FTP and reload BrowserSync (proxied to remote location). But depending on the speed of the upload, sometimes the BrowserSync refresh happens before the file has arrived!
I might be doing something wrong but it seems like it would be good to have a "callback" which accepts a function that fires oncomplete of the upload. Not sure how hard that would be to implement though?
➜ ThousandSunny git:(develop) ✗ npm list ssh2
[email protected] /Users/george/Documents/mall/ThousandSunny
└─┬ [email protected]
└── [email protected]
➜ ThousandSunny git:(develop) ✗ gulp deploy --server production
[20:01:12] Using gulpfile ~/Documents/mall/ThousandSunny/gulpfile.js
[20:01:12] Starting 'deploy'...
[20:01:12] Authenticating with password.
[20:01:14] Connection :: end
[20:01:14] gulp-sftp SFTP abrupt closure
events.js:85
throw er; // Unhandled 'error' event
^
Error: SFTP abrupt closure
I'd like to use this tool from behind a corporate proxy with no direct Internet connection. We have a HTTP proxy available, and I can use for SSH connections via e.g. PuTTY. (Also note that DNS lookups will fail, the proxy has to do the lookup.)
I don't see any proxy options in the documentation for gulp-sftp.
Hi,
what about supporting custom private key file locations? Personally I have a couple of them and the one I need to use is not a default path (like ~/.ssh/id_rsa
). Would be useful to have an option parameter to specify the keyfile location.
What do you think? I could create a pull request.
Cheers
Just wanted to confirm whether .ppk putty keys are not supported in windows, or if I'm doing something wrong.
Cheers.
Hi. Just wanted to inform about that the service fails on symbolic links pointing pointing to a directory.
I think this might be a directory separator thing.
in gulpfile:
gulp.task('deploy-sftp', function() {
return gulp.src('./deploy.zip')
.pipe(sftp({
host: "XXXXXX",
remotePath: "/var/www/html",
auth: 'stage'
}));
});
in .ftppass:
{
"stage": {
"user": "ec2-user",
"key": "C:/Dropbox/.ssh/id_rsa"
}
}
result on server:
new file in /home/ec2-user with the filename: "\var\www\html\deploy.zip" (backslashes are part of the filename) 0 bytes
changes in subdirs are not sent.
the only file in my root is index.html
Have I misconfigured?
gulp.task( 'deploy', function () {
return gulp.src('dist/*')
.pipe(sftp({
host: 'mydomain.com',
user:'tech',
remotePath:'/home/tech/htdocs/',
auth: 'privateKey'
}));
} );
I'm using gulp-sftp to upload the current state of a project to a staging server. Is it possible to clean (e.g. delete all content) of the target folder on the remote machine before uploading?
Since I have a lot of changing files and file structures the target folder gets extremely cluttered with files that have since been moved, renamed or deleted.
Hi man,
Is possible to ignore files and folders?
Regards, Nicholls
[01:29:41] gulp-debug: dist/app
[01:29:41] gulp-debug: dist/assets
[01:29:41] gulp-debug: dist/favicon.ico
[01:29:41] Authenticating with password.
[01:29:41] gulp-debug: dist/index.html
[01:29:41] gulp-debug: 4 items
buffer.js:141
throw new TypeError('must start with number, buffer, array or string');
^
TypeError: must start with number, buffer, array or string
at fromObject (buffer.js:141:11)
at new Buffer (buffer.js:62:10)
at onNEWKEYS (/Users/user/project/node_modules/ssh2/lib/Connection.js:2366:29)
at Parser.<anonymous> (/Users/user/project/node_modules/ssh2/lib/Connection.js:129:5)
at emitNone (events.js:80:13)
at Parser.emit (events.js:179:7)
at Parser.parsePacket (/Users/user/project/node_modules/ssh2/lib/Parser.js:468:12)
at Parser.execute (/Users/user/project/node_modules/ssh2/lib/Parser.js:249:14)
at Socket.<anonymous> (/Users/user/project/node_modules/ssh2/lib/Connection.js:536:18)
at emitOne (events.js:90:13)
I tried to use gulp-sftp in gulpfile.js as such:
var sftpOptions = {
host: 'example.org',
user: 'username',
remotePath: '/home/public_html/'
};
and then, later on
.pipe(sftp(sftpOptions));
I had hoped that gulp-sftp would access my local key I have created with ssh-copy-id
, just as the terminal does, so no storing of passwords or passphrase in redundant places would be necessary. Is that possible?
Though, the following error is produced:
throw new Error('Encrypted private key detected, but no passphrase giv
^
Error: Encrypted private key detected, but no passphrase given
at Connection.connect (/Users/username/project/node_modules/gulp-sftp/node_modules/ssh2/lib/Connection.js:292:15)
at Transform.pool (/Users/username/project/node_modules/gulp-sftp/index.js:209:11)
at Transform.through.obj.finished [as _transform] (/Users/username/project/node_modules/gulp-sftp/index.js:229:14)
at Transform._read (/Users/username/project/node_modules/gulp-sftp/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at Transform._write (/Users/username/project/node_modules/gulp-sftp/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/Users/username/project/node_modules/gulp-sftp/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/Users/username/project/node_modules/gulp-sftp/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Transform.Writable.write (/Users/username/project/node_modules/gulp-sftp/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at DestroyableTransform.ondata (stream.js:51:26)
at DestroyableTransform.emit (events.js:95:17)
Can you help me understand what I am doing and/or expecting wrong?
About Encryption: I have activated Filevault on my mac, but that can't be what it means?
Authenticating with password.
运行后就只显示这条log。为什么没能上传文件。
Files seem to be uploaded successfully but then I always get this error
[12:17:17] Using gulpfile ~/projects/my-app/gulpfile.js
[12:17:17] Starting 'default'...
[12:17:18] Authenticating with private key.
[12:17:18] gulp-sftp: Uploaded: index.html => /usr/share/nginx/html/my-app/index.html
[12:17:18] gulp-sftp: Uploaded: jquery-1.10.2.min.js => /usr/share/nginx/html/my-app/jquery-1.10.2.min.js
[12:17:18] gulp-sftp: Uploaded: thinClient.js => /usr/share/nginx/html/my-app/thinClient.js
[12:17:18] gulp-sftp: 3 files uploaded successfully
events.js:141
throw er; // Unhandled 'error' event
^
Error: SFTP session ended early
at SFTPStream._cleanup (/home/pghalliday/projects/my-app/node_modules/gulp-sftp/node_modules/ssh2/node_modules/ssh2-streams/lib/sftp.js:188:15)
at SFTPStream.end (/home/pghalliday/projects/my-app/node_modules/gulp-sftp/node_modules/ssh2/node_modules/ssh2-streams/lib/sftp.js:160:8)
at SFTPWrapper.end (/home/pghalliday/projects/my-app/node_modules/gulp-sftp/node_modules/ssh2/lib/SFTPWrapper.js:29:23)
at Transform._flush (/home/pghalliday/projects/my-app/node_modules/gulp-sftp/index.js:319:23)
at Transform.<anonymous> (/home/pghalliday/projects/my-app/node_modules/gulp-sftp/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:135:12)
at Transform.g (events.js:260:16)
at emitNone (events.js:72:20)
at Transform.emit (events.js:166:7)
at finishMaybe (/home/pghalliday/projects/my-app/node_modules/gulp-sftp/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:371:12)
at afterWrite (/home/pghalliday/projects/my-app/node_modules/gulp-sftp/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:291:5)
I'm using version 0.1.4
of gulp-sftp and it installed version 0.4.11
of ssh2. Sounded similar to the SFTP abrupt closure
error (although my files are tiny) so i also tried {buffer: false}
in the gulp.src
call but it didn't make any difference.
This is my gulpfile:
var gulp = require('gulp');
var sftp = require('gulp-sftp');
gulp.task('default', function() {
return gulp.src('src/*', {buffer: false})
.pipe(sftp({
host: '10.0.0.10',
user: 'root',
remotePath: '/usr/share/nginx/html/my-app/'
}));
});
The server is a Ubuntu 14.04 LEMP stack running on Digital Ocean
Any thoughts?
If you have a remotePath configured with an heading slash (absolute dir) and you are on windows (client), the dirs are not created (heading slash is somewhere trimmed...)
I tried by passing the pass, etc. and by using a .ftppass
. Same error. Has anyone seen this before? 😦.
...
[14:38:33] Authenticating with password.
[gulp] 'publish-manifest' errored after 10 s Timed out while waiting for handshake
/Users/adam/.../node_modules/gulp/node_modules/orchestrator/index.js:153
throw err;
^
Error: Timed out while waiting for handshake
at [object Object]._onTimeout (/Users/adam/.../node_modules/gulp-sftp/node_modules/ssh2/lib/Connection.js:232:17)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
I have setup a gulp task with gulp-sftp and have tried two sites to connect to it without success. I have tried both sites with Filezilla and both are connecting.
My task is the following:
var sftp = require('gulp-sftp');
gulp.task('sftp', function () {
return gulp.src('dist/**/*')
.pipe(sftp({
host: 'waws-prod-sn1-015.ftp.azurewebsites.windows.net',
user: 'fwd16\$fwd16',
pass: 'xxxxxx',
remotePath: '/site/wwwroot'
}));
});
The respond I am getting is the following:
bash-3.2$ gulp sftp
[22:29:18] Using gulpfile ~/Desktop/gulp-starter-csstricks/gulpfile.js
[22:29:18] Starting 'sftp'...
[22:29:18] Authenticating with password.
[22:29:28] 'sftp' errored after 10 s
[22:29:28] Error in plugin 'gulp-sftp'
Message:
Timed out while waiting for handshake
Details:
level: connection-timeout
[22:29:28] gulp-sftp SFTP abrupt closure
[22:29:28] Connection :: close
I would prefer to use the auth method, as I prefer not to expose the user and pwd in the gulp file and I add the .ftppass to my .gitignore.
If I add the user and pwd in my .ftppass file and change the task to the following:
gulp.task('sftp', function () {
return gulp.src('dist/**/*')
.pipe(sftp({
host: 'waws-prod-sn1-015.ftp.azurewebsites.windows.net',
authFile:'.ftppass',
auth: 'keyMain',
remotePath: '/site/wwwroot'
}));
});
I get the following error:
bash-3.2$ gulp sftp
[22:22:55] Using gulpfile ~/Desktop/gulp-starter-csstricks/gulpfile.js
[22:22:55] Starting 'sftp'...
[22:22:55] 'sftp' errored after 7.52 ms
[22:22:55] SyntaxError: Unexpected token $ in JSON at position 36
at Object.parse (native)
at module.exports (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/gulp-sftp/index.js:33:25)
at Gulp.<anonymous> (/Users/sohail/Desktop/gulp-starter-csstricks/gulpfile.js:86:15)
at module.exports (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/orchestrator/index.js:134:8)
at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:592:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Anyone understand what I missing in my code?
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.