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

chef-run on windows 10 ignore build-in ssh config for key #157

Open
herz0g opened this issue Nov 25, 2019 · 2 comments
Open

chef-run on windows 10 ignore build-in ssh config for key #157

herz0g opened this issue Nov 25, 2019 · 2 comments
Labels
Triage: Confirmed Indicates and issue has been confirmed as described. Type: Bug Does not work as expected.

Comments

@herz0g
Copy link

herz0g commented Nov 25, 2019

Description

Hi, when I start chef-run I got error messages that my ssh config file isn't setup correctly. I have a ssh config file in my home folder which one is working if I use build-in ssh - it will connect to the definied server and ask for the definied key within my config file:

PS C:\Users\chg> ssh mailsrv
Enter passphrase for key '.\.ssh\id_rsa':
...

But it is not working if I use chef-run:

PS C:\Users\chg\Documents\chef-repo\cookbooks\debian10_sec\recipes> chef-run mailsrv default.rb
 [✔] Packaging cookbook... done!
 [✔] Generating local policyfile... exporting... done!
[✖] Applying debian10_sec::default from C:/Users/chg/Documents/chef-repo/cookbooks/debian10_sec to target.              |__ [✖] [mailsrv] No authentication methods available.                                                                  
No authentication methods available.
Try...
- Provide a password with "--password PASSWORD"
- Provide a key with "-identity-file PATH/TO/FILE"
- Enable ssh-agent and add keys
- Add a host entry to your ssh configuration

Additional instructions can be found in the troubleshooting documentation:
https://www.chef.sh/docs/chef-workstation/troubleshooting/#error-code-cheftrn007

Where do chef-run search for the config file?

Chef Workstation Version

Chef Workstation version: 0.11.21
Chef Infra Client version: 15.4.45
Chef InSpec version: 4.18.0
Chef CLI version: 2.0.0
Test Kitchen version: 2.3.4
Cookstyle version: 5.10.13
chef-run: 0.4.6

Platform Version

Windows 10 Pro (1909)

stack-trace:

--------------------------------------------------------------------------------
2019-11-25 16:24:24 +0100: Error encountered while running the following:
  mailsrv default.rb
Backtrace:
ChefApply::TargetHost::ConnectionFailure: ChefApply::TargetHost::ConnectionFailure
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-apply-0.4.6/lib/chef_apply/target_host.rb:131:in `rescue in connect!'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-apply-0.4.6/lib/chef_apply/target_host.rb:114:in `connect!'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-apply-0.4.6/lib/chef_apply/cli.rb:334:in `do_connect'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-apply-0.4.6/lib/chef_apply/cli.rb:180:in `connect_target'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-apply-0.4.6/lib/chef_apply/cli.rb:165:in `block (2 levels) in render_converge'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-apply-0.4.6/lib/chef_apply/ui/terminal/job.rb:31:in `run'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-apply-0.4.6/lib/chef_apply/ui/terminal.rb:60:in `block (2 levels) in render_parallel_jobs'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/tty-spinner-0.9.1/lib/tty/spinner.rb:225:in `execute_job'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/tty-spinner-0.9.1/lib/tty/spinner/multi.rb:150:in `block (2 levels) in auto_spin'
Caused by: Train::ClientError: Your SSH Agent has no keys added, and you have not specified a password or a key file
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/train-core-3.1.4/lib/train/transports/ssh.rb:106:in `validate_options'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/train-core-3.1.4/lib/train/transports/ssh.rb:76:in `connection'
	C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-apply-0.4.6/lib/chef_apply/target_host.rb:118:in `connect!'
	... 7 more
@herz0g
Copy link
Author

herz0g commented Nov 25, 2019

Update

I had to remove my password for the key file, after that I was able to use the -i argument and got my key accepted. But it isn't working with my config file or ssh-add. Booth ways are ignored when I run chef-run. I think chef-run don't search for the config file in ~.ssh\config, seems that it is try to find the keys within another path?

/Update

Also:

added my key with ssh-add after enabling ssh-agent
-> not working, same error like above

added the key file with argument -i for chef-run
-> error:

2019-11-25 21:56:20 +0100: Error encountered while running the following:
  mailsrv -i C:\Users\chg\.ssh\id_rsa default.rb
Backtrace:
Caused by: Train::Transports::SSHFailed: SSH command failed (the given identity is known, but the private key could not be loaded: OpenSSL::PKey::PKeyError (Could not parse PKey: no start line))

@afiune
Copy link

afiune commented Dec 11, 2019

Hello @herz0g - Thank you for reporting this issue, we have confirmed that this is
a bug and we will investigate what are the complication on Windows systems. We will
keep you posted of any discovery or fixes we do.

@tas50 tas50 transferred this issue from chef/chef-workstation Feb 13, 2021
@marcparadise marcparadise added Triage: Confirmed Indicates and issue has been confirmed as described. Type: Bug Does not work as expected. labels Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage: Confirmed Indicates and issue has been confirmed as described. Type: Bug Does not work as expected.
Projects
None yet
Development

No branches or pull requests

3 participants