PM2 deploy, user password?

Viewed 878

I try to use pm2 deploy but i don't find how to integrate user password in config file (https://pm2.keymetrics.io/docs/usage/deployment/):

{
   "apps" : [{
      "name" : "HTTP-API",
      "script" : "http.js"
   }],
   "deploy" : {
     // "production" is the environment name
     "production" : {
       "user" : "ubuntu",
       "host" : ["xxxxxxxx"],
       "ref"  : "origin/master",
       "repo" : "git@github.com:Username/repository.git",
       "path" : "/var/www/my-repository",
       "post-deploy" : "npm install; grunt dist"
      },
   }
}

I'm not able to run npm install on my server without sudo, according to this, how can i pass the password inside this config?

================= SOLUTIONS ===================

The only solution i found is to pass directly the password in my command line and read it with sudo -S :

production: {
      key: "/home/xxxx/.ssh/xxx.pem",
      user: "xxx",

      host: ["xxxxxxxx"],
      ssh_options: "StrictHostKeyChecking=no",
      ref: "origin/xxxx",
      repo: "xxxxx@bitbucket.org:xxxx/xxxxx.git",
      path: "/home/xxxx/xxxxxx",

      'pre-setup': "echo '## Pre-Setup'; echo 'MYPASS' |sudo -S bash setup.sh;",
      'post-setup': "echo '## Post-Setup'",
      'post-deploy': "echo 'MYPASS' |sudo -S bash start.sh; ",
    }
1 Answers

As I understand, there is no option for ssh password in pm2 deploy, only keys.

Related