How to copy a folder over SSH with Gulp?
build, gulp, javascript, scp, ssh
Solution
I did end up finding a solution by leveraging the node `scp2` library:
scpClient = require('scp2');
gulp.task('scp', [], function (cb) {
scpClient.scp('local_folder', {
"host": "remote_host",
"port": "remote_port",
"username": "username_on_remote",
"path": "/path/on/remote",
"agent": process.env["SSH_AUTH_SOCK"],
"agentForward": true
}, cb)
});
Problem
I have been experimenting with gulp lately, and have had a lot of success, but now I am stumped. I have gulp building everything, and I want to upload a folder afterwards. I have created a `deploy` task for this using `gulp-scp2`: ``` gulp.task('deploy', ['clean', 'build'], function() { var privateKeyPath = getUserHome() + '/.ssh/id_rsa'; gulp.src('public/dist') .pipe(scp({ host: 'myhost', username: 'user', dest: '/home/user/test', agent: process.env['SSH_AUTH_SOCK'], agentForward: true, watch: function(client) { client.on('write', function(o) { console.log('write %s', o.destination); }); } })).on('error', function(err) { console.log(err); }); }); ``` Unfortunately, when I do this, I get the following error: ``` Error: Content should be buffer or file descriptor ``` How can I copy a folder over SSH using gulp?