Search code examples
windowssshgulpcygwin

How to use ssh key with gulp-rsync and cygwin


I am using a gulp task to deploy my application, like this (in this example I am omitting the real values)

gulp.task('deploy', function () {
return gulp.src(config.deployFiles)
        .pipe(rsync({
            root: 'build/',
            hostname: 'hostname',
            username: 'username',
            destination: 'destination'
     }));});

However,the command fails with

gulp-rsync: Permission denied (publickey).

Note: I can access the remote server through ssh, the point is how to tell cygwin to use the right ssh key so that gulp-rsync can use it?


Solution

  • This is the solution I found so far. In a cygwin terminal run

    ssh-host-config
    

    it will create a config file into the cygwin/etc folder (/etc/ssh_config). Then, add to that file a host entry

      Host hostnameToUse
           Hostname xx.xx.xx.xx.xx
           Port 22
           IdentityFile D:\keys\vps
    

    Then update the hostname in the gulp task to 'hostnameToUse' gulp deploy works:

    gulp-rsync: sending incremental file list....