dasuchin / grunt-ssh-deploy

Grunt SSH Deployment
MIT License
66 stars 45 forks source link

deploy with agent #16

Closed lietzi closed 9 years ago

lietzi commented 9 years ago

Hi,

i just tried to deploy with thesse settings - but it did not work:

      environments: {
          staging: {
              options: {
                  host: 'host.de',
                  port: 22,
                  agent: process.env.SSH_AUTH_SOCK,
                  deploy_path: '/var/www/test/',
                  local_path: 'dist',
                  current_symlink: 'current',
                  debug: true
              }
          }
      }

The only errormessage was:

Warning: Password or private key required.

I thought, the input of password or key was not necessary with agent?

using ssh host.de in terminal works as expected..

thx for your help!

greetings

lochstar commented 9 years ago

What operating system?

hurricane766 commented 9 years ago

See here

I had a similar issue and just commented out the line because I'm only ever using agent not password or privatekey.

You could also just set privatekey to point to your local private key file.

Also notice that 'agent' isn't actually used in the code anywhere and could be left out entirely. I believe the default would be for the process to use the environment's private key(s).

lietzi commented 9 years ago

i'm currently working on manjaro-linux.. but sometimes at win7.. so it would be nice to use something 'system-neutral' in the gruntfile..

moreover i don't like to save my credentials unencrypted elsewhere.. especially the pass-phrase of my ssh-private-key..

the agent is mentioned in this options-listing - it should be possible to use it!

@hurricane766 When i commented out the mentioned line it did not work either.

Fatal error: Argument must be a string
hurricane766 commented 9 years ago

@lietzi try also commenting out lines 19 - 22. or if (options.agent) { //default key will be used } else if (options.privateKey) { scpOptions.privateKey = options.privateKey } else { scpOptions.password = options.password; }

lietzi commented 9 years ago

@hurricane766 thx. now i can connect to server via agent - and the releases folders are created - but the upload stuck with this:

Fatal error: Timed out while waiting for handshake

scp from terminal works normal.. & readyTimeout: 99999 is set..

:(

hurricane766 commented 9 years ago

@lietzi sorry, not too sure what's going on. If it created the releases folder then it did connect, but sounds like it's timing out waiting for the client.scp() . You could try modifing the scpBuild function to operate like other commands and just use a command string instead of the client.scp call - since you're saying that the scp works from the terminal.

lochstar commented 9 years ago

Following on from what @hurricane766 said, you could try replacing scpBuild with the following tarBuild function I've been using. This has been my preferred method of deployment, I've found transfer speeds to be much faster.

var tarBuild = function(callback) {
    var remote_string = 'ssh ' + options.username + '@' + options.host + ' -p' + options.port + ' "tar -C ' + options.deploy_path + '/releases/' + timestamp + '/' + ' -jxf -"'
    var command = 'tar -C ' + options.local_path + ' -jcf - ./ | ' + remote_string;
    grunt.log.subhead('UPLOADING NEW BUILD');
    grunt.log.writeln('>> ' + command);
    execLocal(command, callback);
};
hurricane766 commented 9 years ago

Deploying with agent should be working in the current version. Close?