Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should I rsync with Amazon EC2 using *.pem key? #45

Open
owen26 opened this issue Jan 19, 2017 · 2 comments
Open

How should I rsync with Amazon EC2 using *.pem key? #45

owen26 opened this issue Jan 19, 2017 · 2 comments

Comments

@owen26
Copy link

owen26 commented Jan 19, 2017

The rsync command would looks similar to this:
rsync -rave "ssh -i /path/to/my/key.pem" example/* [email protected]:/var/www/html/example/

I'm wondering how do I achieve the same thing on gulp-rsync ?

@capa89k
Copy link

capa89k commented Mar 28, 2018

I am not sure if gulp-rsync support private/public key option for connection, but I suppose you can configure your ssh client in order to use the key.pem file whenever you connect to a specific host.

Just create a file config inside the folder $HOME/.ssh/ and write something like this:

Host example
        HostName example.com
        Port 22
        User username
        IdentityFile /path/to/my/key.pem

Then you can connect with gulp-rsync using as hostname the label name "example".

var rsyncConf = {
    ...
    hostname: 'example',
    username: 'username',
    ...
};

@sangtcao
Copy link

Just recently came into this issue and managed to put it together. Since no one else on the web posted a solution, figured I'd do my duty here and pass it along. Hope it can still be useful to others:

gulp-rsync doesn't support this by default, but back in 2015 there was an added feature for any custom options when running the command (#17). You can attach the -e option to your shell command like so:

var gulp = require('gulp');
var rsync = require('gulp-rsync');

gulp.task('deploy', function() {
  gulp.src('build/**')
    .pipe(rsync({
      username: 'user',
      hostname: 'host',
      destination: '~/',

      options: {
        "e": "ssh -i <local-path-to-key-file>"
      }

    }));
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants