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

genesis:provision should setup password-less SSH #131

Merged
merged 3 commits into from
Jun 27, 2014

Conversation

EvanK
Copy link
Contributor

@EvanK EvanK commented Jun 25, 2014

Because Capistrano ~2.15 (thanks to net-ssh 2.8.0) has issues with password authentication, I think the best course is for genesis:provision -S user=... -S password=... to use the credentials locally to setup the server for public-key authentication.

Here's a trick to using expect to SSH into a machine with a user/pass & execute a command:

$ expect -c 'spawn ssh $USER@$HOST; \
             expect password;       \
             send "$PASSWORD\n";    \
             expect "$ ";           \
             send "$COMMAND\r";     \
             expect "$ ";           \
             send "exit\r";'

@ericclemmons
Copy link
Contributor Author

@jameswlane has a similar bash script going:

https://gist.github.com/jameswlane/0e35413386be134477da

@EvanK
Copy link
Contributor

EvanK commented Jun 24, 2014

That's pretty much exactly what I'm doing now, but I'm trying to integrate it into our genesis:provision task with ruby's built-in expect implementation.

@jameswlane
Copy link
Contributor

If there is anything I can do to help out let me know. I am not familiar with expect, but that route sounds a lot better for the end user.

@EvanK
Copy link
Contributor

EvanK commented Jun 25, 2014

I tested this against a local vagrant machine -- several times! -- and it seems to work:

  • Initial provision without a user/pass fails with helpful error, as expected - see gist
  • Initial provision with a user/pass succeeds when the workaround kicks in - see gist
  • Re-provision with a user/pass succeeds with the workaround - see gist
  • Re-provision without user/pass succeeds w/o workaround, since private key auth already exists - see gist

@ericclemmons
Copy link
Contributor Author

Easy way to test:

bower install --save #131-provision-password-fix

/cc @weeirishman @EvanK

@weeirishman
Copy link
Contributor

Worked perfectly for me, thanks guys.

EvanK added 2 commits June 27, 2014 14:33
This should give us some output of the PTY process, & make debugging easier if/when it busts
@EvanK
Copy link
Contributor

EvanK commented Jun 27, 2014

Added some verbose output to make debugging easier, but I believe this fix is ready to roll!

EvanK added a commit that referenced this pull request Jun 27, 2014
net-ssh workaround for genesis:provision task
@EvanK EvanK merged commit f2c306c into master Jun 27, 2014
@ericclemmons
Copy link
Contributor Author

Whoops, this wasn't tagged for release. Do you want me to take care of it @EvanK ?

@EvanK
Copy link
Contributor

EvanK commented Jun 28, 2014

Sure

@ericclemmons
Copy link
Contributor Author

Done!

7bd30db...3174a7f

Thanks for your help @EvanK!

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

Successfully merging this pull request may close these issues.

4 participants