teambition / gulp-ssh

SSH and SFTP tasks for gulp
184 stars 38 forks source link

sftp does not work with agentForward #23

Closed oleynikd closed 9 years ago

oleynikd commented 9 years ago

Hi,

Here's the config:

var gulpSSH = require('gulp-ssh')({
    ignoreErrors: false,
    sshConfig: {
        host: 'myhost',
        username: 'root',
        port: 22,
        agent: process.env["SSH_AUTH_SOCK"],
        agentForward: true
    }
});

With this config gulpSSH.shell() works great! But gulpSSH.sftp() does NOT! It freezes on 'gulp-ssh :: Connect...' and then 'Timed out while waiting for handshake'

oleynikd commented 9 years ago

I am sorry, problem is not with agentForward. This code does not work:

gulp.task('sftp-write', function () {
    var allFiles = ["./**/*", "!Gruntfile.js", "!gulpfile*.js", "!Icon*", "!*.json", "!**/*.map", "!assets{,/**}", "!bower_components{,/**}", "!node_modules{,/**}"];
    return gulp.src(allFiles)
        .pipe(zip(package.name+'.zip'))
        .pipe(gulpSSH.sftp('write', '/var/www/fm/flatmaterial.com/feta/wp-content/themes/test.js'));
});

Seems like gulpSSH.sftp doesn't like glob as src...? How can I handle this? Thanks.

zensh commented 9 years ago

sftp write will failed if dirs not exist.

I have released v0.5.0, It support dest, that copy the files to remote through sftp, acts similarly to Gulp dest, will make dirs if not exist. (Thanks to @danrien )

A simple demo:

  gulp.task('dest', function () {
    return gulp
      .src(['./**/*.js', '!**/node_modules/**'])
      .pipe(gulpSSH.dest('/home/iojs/test/gulp-ssh/'))
  })
oleynikd commented 9 years ago

This works great!!! Thank you VERY MUCH!!!