Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
gulp-sftp-up4
Advanced tools
Upload files via SSH and working with gulp 4.0. Fork of original gulp-sftp
This is fork of original gulp-sftp with little change which let us to use it with gulp 4.0 version It solve error: "TypeError: file.pipe is not a function". This solution is by Dan503 https://github.com/gtg092x/gulp-sftp/issues/78#issuecomment-356475605 And what I did - is just public it in npm with name "gulp-sftp-up4"
Original README text below: (Just use new name gulp-sftp-up4)
Upload files via SSH
Useful for uploading and deploying things via sftp. Right now this plugin just uploads everything. Caching and hash comparison are two TODO items.
$ npm install --save-dev gulp-sftp-up4
var gulp = require('gulp');
var sftp = require('gulp-sftp-up4');
gulp.task('default', function () {
return gulp.src('src/*')
.pipe(sftp({
host: 'website.com',
user: 'johndoe',
pass: '1234'
}));
});
Required
Type: String
Type: Number
Default: 22
Type: String
Default: 'anonymous'
Type: String
Default: null
If this option is not set, gulp-sftp assumes the user is using private key authentication and will default to using keys at the following locations:
~/.ssh/id_dsa
and /.ssh/id_rsa
If you intend to use anonymous login, use the value '@anonymous'.
Type: String
Default: '/'
The remote path to upload to. If this path does not yet exist, it will be created, as well as the child directories that house your files.
Type: String
Default: 'unix'
The remote platform that you are uploading to. If your destination server is a Windows machine, use the value windows
.
type String
or Object
Default: null
A key file location. If an object, please use the format {location:'/path/to/file',passphrase:'secretphrase'}
type String
Default: null
A passphrase for secret key authentication. Leave blank if your key does not need a passphrase.
type String
Default: null
If you wish to pass the key directly through gulp, you can do so by setting it to options.keyContents.
type String
Default: null
An identifier to access authentication information from .ftppass
see Authentication for more information.
type String
Default: .ftppass
A path relative to the project root to a JSON formatted file containing auth information.
type int
Default: Currently set by ssh2 as 10000
milliseconds.
An integer in milliseconds specifying how long to wait for a server response.
type String
Default: null
Path to ssh-agent's UNIX socket for ssh-agent-based user authentication.
type bool
Default: false
Set to true to use OpenSSH agent forwarding. Requires that options.agent
is configured.
type function
Default: null
Callback function to be called once the SFTP connection is closed.
##Authentication
For better security, save authentication data in a json formatted file named .ftppass
(or to whatever value you set options.authFile to). Be sure to add this file to .gitignore. You do not typically want auth information stored in version control.
var gulp = require('gulp');
var sftp = require('gulp-sftp');
gulp.task('default', function () {
return gulp.src('src/*')
.pipe(sftp({
host: 'website.com',
auth: 'keyMain'
}));
});
.ftppass
{
"keyMain": {
"user": "username1",
"pass": "password1"
},
"keyShort": "username1:password1",
"privateKey": {
"user": "username"
},
"privateKeyEncrypted": {
"user": "username",
"passphrase": "passphrase1"
},
"privateKeyCustom": {
"user": "username",
"passphrase": "passphrase1",
"keyLocation": "/full/path/to/key"
}
}
##Work with pem
To use pem create private keys and certificates for access your server:
var pem = require('pem');
gulp.task('deploy:test', function () {
pem.createCertificate({}, function (err, kyes) {
return gulp.src('./src/**/*')
.pipe(sftp({
host: 'testserver.com',
user: 'testuser',
pass: 'testpass',
key: kyes.clientKey,
keyContents: kyes.keyContents
}));
});
});
##Known Issues
###SFTP error or directory exists: Error: No such file /remote/sub/folder
Version 0.1.2 has an issue for Windows clients when it comes to resolving remote paths. Please upgrade to 0.1.3.
###Error:: SFTP abrupt closure
Some conditions can cause the ssh2 connection to abruptly close. The issues that commonly cause this are large files (though they are checked for and are automatically converted to streams) and heavy memory usage.
To solve problems related to ssh2 closures, try to use streams instead of buffers. Do this by passing {buffer:false}
as an option with gulp.src
. This isn't always an option, so I would suggest exploring ways to move between streams and buffers. Lars Kappert has a great article on managing this.
Some awesome work via @mscdex addressed this issue. Please make sure you have the latest version or greater of gulp-sftp (0.1.1) and the latest version or greater of ssh2 (0.3.4) and you should not see abrupt disconnects with large files.
FAQs
Upload files via SSH and working with gulp 4.0. Fork of original gulp-sftp
The npm package gulp-sftp-up4 receives a total of 0 weekly downloads. As such, gulp-sftp-up4 popularity was classified as not popular.
We found that gulp-sftp-up4 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.