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

Add (encrypted) SSH Key to Travis-CI for (Continuous) Deployment #42

Closed
4 tasks done
nelsonic opened this issue May 25, 2018 · 10 comments
Closed
4 tasks done

Add (encrypted) SSH Key to Travis-CI for (Continuous) Deployment #42

nelsonic opened this issue May 25, 2018 · 10 comments

Comments

@nelsonic
Copy link
Member

nelsonic commented May 25, 2018

In order to deploy "review apps" from Travis-CI we need to:

@nelsonic
Copy link
Member Author

Last night I spent around 4h trying to debug using an SSH Key (with a passphrase) on Travis-CI ...
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384010921#L521
image

Essentially: having a passphrase on the SSH key leads to the SSH call to "hang"
because the session stays "logged-in" via SSH ...
There is no way to "exit" the session (that I can find through extensive googling)

My conclusion is that I need to open a StackOverflow Question for this and move on!
(and if I get an answer to my SO Q, I can return to SSH Keys with passwords ...)

Ah... It's right there!!
image
image

This is wasting my time! 😞

nelsonic added a commit to nelsonic/hello-world-node-http-server that referenced this issue May 26, 2018
@nelsonic
Copy link
Member Author

Posted this question: https://stackoverflow.com/questions/50542947/how-to-run-ssh-commands-from-bash-when-rsa-key-has-a-password

Now I'm going to try this using an RSA Key without a password.
I would delighted if someone on SO can help me with my Quest,
but to avoid wasting anymore time on this "dead end",
I'm just going to crack on.

@nelsonic
Copy link
Member Author

On advice from "chepner" on SO I'm trying out ssh-agent 🤞
see: https://www.ssh.com/ssh/add

nelsonic added a commit to nelsonic/hello-world-node-http-server that referenced this issue May 26, 2018
nelsonic added a commit to nelsonic/hello-world-node-http-server that referenced this issue May 26, 2018
nelsonic added a commit to nelsonic/hello-world-node-http-server that referenced this issue May 26, 2018
nelsonic added a commit to nelsonic/hello-world-node-http-server that referenced this issue May 26, 2018
nelsonic added a commit to nelsonic/hello-world-node-http-server that referenced this issue May 26, 2018
@nelsonic
Copy link
Member Author

obviously that errors:
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384156902#L453
image

So now, after a bit more googling, I'm trying the -pass "pass:$SSH_ASKPASS" flag
in RSA key decryption stage ... 🤞

⌛️

obviously that errors too:
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384160512#L451
image

A least the error message "bad magic number" is amusing (though unhelpful...)

I feel like I've looked at all the StackOverflow / SuperUser / ServerFault / Unix questions/answers on this ... 😞

Now getting:

$ ssh-add ./deploy_key
Enter passphrase for ./deploy_key: 

https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384165098#L458
image

Trying o use expect command to enter the password for me:

- expect << EOF
    expect "Enter passphrase"
    send "$SSH_ASKPASS\r"
    expect eof
  EOF

via: https://stackoverflow.com/a/13034313/1148249
Got: https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384167872#L458
image

"dry run" of installing expect worked:
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384168360#L462
image

via: https://askubuntu.com/questions/920879/why-so-many-dependencies-for-package-expect

@nelsonic
Copy link
Member Author

Ok, I've "wrestled" with this "long enough".
expect was a "dead end".
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384178154#L479
image

I really wish I had someone to pair on this with ... 😞

@nelsonic
Copy link
Member Author

On the advice of @pynexj I'm trying: https://github.com/clarkwang/passh
image

Just reading the source https://github.com/clarkwang/passh/blob/master/passh.c now ...

@nelsonic
Copy link
Member Author

The script compiles: (but then Travis can't find the executable...)
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384181218
image

So now I'm trying to use ./passh ...
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384182301#L472
image

Enter passphrase for key './deploy_key': 

looks like I'm "back to square one" ... 😢

nelsonic added a commit to nelsonic/hello-world-node-http-server that referenced this issue May 26, 2018
@nelsonic
Copy link
Member Author

OK ... I've opened an issue on the passh repo: clarkwang/passh#2
Feeling like this is the "end of the line" for this Quest ... (at least for today...)

Who else is spending their ("Bank Holiday Weekend") Saturday debugging SSH deployment ...?!
What is wrong with me...?!
Surely there are "better" things to be doing ... like "Socialising" or "Sofa + Netflix"...? 🙄

@nelsonic
Copy link
Member Author

Using an RSA Key without a password is easy:
https://travis-ci.org/nelsonic/hello-world-node-http-server/builds/384217141#L501
image

Let's crack on with this! 👍

@nelsonic
Copy link
Member Author

This is totes working and PR is ready for review. 👍

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

No branches or pull requests

2 participants