Unitech / pm2-deploy

Deploy part of PM2
http://pm2.keymetrics.io/docs/usage/deployment/
MIT License
178 stars 71 forks source link

Deploying to EC2 instance via NAT #107

Open joeyfigaro opened 7 years ago

joeyfigaro commented 7 years ago

@Unitech

I'm currently trying to deploy to an EC2 instance sitting behind a NAT. My deployment chain looks like this:

add pem to ssh-agent -> connect to nat -> connect to instance -> pull changes -> build and restart

"production": {
    "key": "~/.ssh/imakey.pem",
    "user": "imauser",
    "host": "imalong.url.amazonaws.com",
    "ref": "origin/master",
    "repo": "git@github.com:somecompany/some-repo.git",
    "path": "~/some-repo"
}

Every time I try to deploy, it hits the NAT, attempts to connect to the instance, and gets killed because it doesn't have permission. Which I'm assuming means it didn't properly add the pem to the agent.

I'm currently specifying the key in my production config. I've also tried using a connection script on my machine via "pre-deploy-local": "~/ssh-script.sh" which also fails, despite working when I use it outside of PM2. I've also tried using "ssh_options": ["-A", "-i ~/.ssh/imakey.pem"] to no avail. No combination of any of these seems to actually use the pem file.

Any ideas?

vmarchaud commented 7 years ago

@joeyfigaro Please come over our slack http://slack.pm2.io/ and pm me to discuss about it

joeyfigaro commented 7 years ago

@vmarchaud I'm in. No one else is on, so I'll hang around until we connect.