在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):gtg092x/gulp-sftp开源软件地址(OpenSource Url):https://github.com/gtg092x/gulp-sftp开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-sftp
Useful for uploading and deploying things via sftp. Right now this plugin just uploads everything. Caching and hash comparison are two TODO items. Install$ npm install --save-dev gulp-sftp Usagevar gulp = require('gulp');
var sftp = require('gulp-sftp');
gulp.task('default', function () {
return gulp.src('src/*')
.pipe(sftp({
host: 'website.com',
user: 'johndoe',
pass: '1234'
}));
}); APIsftp(options)options.hostRequired options.portType: options.userType: options.passType: 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:
If you intend to use anonymous login, use the value '@anonymous'. options.remotePathType: 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. options.remotePlatformType: The remote platform that you are uploading to. If your destination server is a Windows machine, use the value options.keytype A key file location. If an object, please use the format options.passphrasetype A passphrase for secret key authentication. Leave blank if your key does not need a passphrase. options.keyContentstype If you wish to pass the key directly through gulp, you can do so by setting it to options.keyContents. options.authtype An identifier to access authentication information from options.authFiletype A path relative to the project root to a JSON formatted file containing auth information. options.timeouttype An integer in milliseconds specifying how long to wait for a server response. options.agenttype Path to ssh-agent's UNIX socket for ssh-agent-based user authentication. options.agentForwardtype Set to true to use OpenSSH agent forwarding. Requires that options.callbacktype Callback function to be called once the SFTP connection is closed. ##Authentication For better security, save authentication data in a json formatted file named var gulp = require('gulp');
var sftp = require('gulp-sftp');
gulp.task('default', function () {
return gulp.src('src/*')
.pipe(sftp({
host: 'website.com',
auth: 'keyMain'
}));
});
{
"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 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. License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论