train icon indicating copy to clipboard operation
train copied to clipboard

Fixed ssh connection issue if key_files array is empty

Open sanga1794 opened this issue 3 years ago • 8 comments

Signed-off-by: sanga17 [email protected]

Description

If key_files set as empty array then failing to ssh connection while bootstrapping the node

Related Issue

https://github.com/chef/chef/issues/7053

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New content (non-breaking change)
  • [ ] Breaking change (a content change which would break existing functionality or processes)

Checklist:

  • [x] I have read the CONTRIBUTING document.

sanga1794 avatar Jun 30 '21 15:06 sanga1794

Hello sanga1794! Thanks for the pull request!

Here is what will happen next:

  1. Your PR will be reviewed by the maintainers.
  2. Possible Outcomes a. If everything looks good, one of them will approve it, and your PR will be merged. b. The maintainer may request follow-on work (e.g. code fix, linting, etc). We would encourage you to address this work in 2-3 business days to keep the conversation going and to get your contribution in sooner. c. Cases exist where a PR is neither aligned to Chef InSpec's product roadmap, or something the team can own or maintain long-term. In these cases, the maintainer will provide justification and close out the PR.

Thank you for contributing!

chef-expeditor[bot] avatar Jun 30 '21 15:06 chef-expeditor[bot]

Is there a bug to link here and can we get a test added for this?

tas50 avatar Jun 30 '21 16:06 tas50

Is there a bug to link here and can we get a test added for this?

@tas I'm working on the issue https://github.com/chef/chef/issues/7053, while trying to bootstrap a node using the ssh config_file, as key_files from chef repo is [](if we didn't mentioned in CLI), then not able to connect with the node using ssh.

sanga1794 avatar Jul 01 '21 15:07 sanga1794

@tas50, @marcparadise Please review this PR Thanks!!

sanga1794 avatar Jul 06 '21 12:07 sanga1794

How does having an empty array for key_files cause a failure?

marcparadise avatar Jul 27 '21 18:07 marcparadise

How does having an empty array for key_files cause a failure?

@marcparadise below i attached the screenshot which consist of both failing and working Net::SSH.start method, please have look. Thanks!! And we are deleting from list of options if value of any variable is nil for reference: https://github.com/inspec/train/blob/7121af0ea78734e4bf8081f14fb72a5f85378477/lib/train/transports/ssh_connection.rb#L213 Screenshot from 2021-07-28 15-52-28

sanga1794 avatar Jul 28 '21 10:07 sanga1794

How does having an empty array for key_files cause a failure?

@marcparadise below i attached the screenshot which consist of both failing and working Net::SSH.start method, please have look. Thanks!! And we are deleting from list of options if value of any variable is nil for reference:

https://github.com/inspec/train/blob/7121af0ea78734e4bf8081f14fb72a5f85378477/lib/train/transports/ssh_connection.rb#L213

Screenshot from 2021-07-28 15-52-28

@marcparadise, @tas50 Please have look into this. Thanks!!!

sanga1794 avatar Aug 30 '21 05:08 sanga1794

If auth method were public-key,keyboard-interactive I'd then expect to receive a password prompt (if tty enabled). With just public-key if the key is not present, it can't succeed. Based on that understanding, it seems like what you're seeing is correct.

Is there something different that you'd expect, or am I misunderstanding something in that output?

marcparadise avatar Sep 16 '21 21:09 marcparadise