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

Cannot run a recipe on my server via SSH with chef-run - authentication fails #2634

Open
mkkekkonen opened this issue Mar 4, 2022 · 3 comments
Labels
Status: Untriaged An issue that has yet to be triaged.

Comments

@mkkekkonen
Copy link

Description

I seemingly cannot run a recipe on my virtual server via SSH with chef-run. Specifically, chef-run is never prompting me for my SSH key passphrase.

Am I missing something? I don't know if there is something in my environment that is causing the problem. I can SSH to the server without problems with the command below:

ssh [email protected] -i .\keyfile.pem

Chef Version

Chef Workstation version: 22.2.802
Chef Habitat version: 1.6.420
Test Kitchen version: 3.2.2
Cookstyle version: 7.31.7
Chef Infra Client version: 17.9.52
Chef InSpec version: 4.52.9
Chef CLI version: 5.6.1

Platform Version

Windows 10 Home, Version 21H1, OS Build 19043.1526

Replication Case

Run something like

chef-run [email protected] -i .\keyfile.pem .\recipes\default.rb

in a Chef cookbook directory

Client Output

[✔] Packaging cookbook... done!
[✔] Generating local policyfile... exporting... done!
[✖] Applying purkki::mathApi from C:/Users/mkkek/Documents/cookbooks/purkki to target.
|__ [✖] [mkkekkonen.fi] Connection failed: Authentication failed for user <user>@mkkekkonen.fi

Connection failed: Authentication failed for user <user>@mkkekkonen.fi

The following error occured while attempting to connect and authenticate to the target.

Authentication failed for user <user>@mkkekkonen.fi

Stacktrace

2022-03-04 10:21:12 +0200: Error encountered while running the following:
  <user>@mkkekkonen.fi -i .\<keyfile>.ppk .\recipes\mathApi.rb
Backtrace:
ChefApply::TargetHost::ConnectionFailure: ChefApply::TargetHost::ConnectionFailure
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/chef-apply-0.9.2/lib/chef_apply/target_host.rb:130:in `rescue in connect!'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/chef-apply-0.9.2/lib/chef_apply/target_host.rb:113:in `connect!'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/chef-apply-0.9.2/lib/chef_apply/cli.rb:332:in `do_connect'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/chef-apply-0.9.2/lib/chef_apply/cli.rb:178:in `connect_target'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/chef-apply-0.9.2/lib/chef_apply/cli.rb:163:in `block (2 levels) in render_converge'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/chef-apply-0.9.2/lib/chef_apply/ui/terminal/job.rb:31:in `run'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/chef-apply-0.9.2/lib/chef_apply/ui/terminal.rb:59:in `block (2 levels) in render_parallel_jobs'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/tty-spinner-0.9.3/lib/tty/spinner.rb:225:in `execute_job'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/tty-spinner-0.9.3/lib/tty/spinner/multi.rb:150:in `block (2 levels) in auto_spin'
Caused by: Train::Transports::SSHFailed: SSH session could not be established
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh_connection.rb:217:in `rescue in establish_connection'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh_connection.rb:206:in `establish_connection'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh_connection.rb:292:in `session'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh_connection.rb:250:in `run_command_via_connection'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/plugins/base_connection.rb:149:in `run_command'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/helpers/os_windows.rb:9:in `check_cmd'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/helpers/os_windows.rb:4:in `detect_windows'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/specifications/os.rb:20:in `block in load_windows'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/scanner.rb:44:in `instance_eval'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/scanner.rb:44:in `block in scan_children'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/scanner.rb:43:in `each'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/scanner.rb:43:in `scan_children'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/scanner.rb:31:in `block in scan'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/scanner.rb:25:in `each'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect/scanner.rb:25:in `scan'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/platforms/detect.rb:7:in `scan'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/plugins/base_connection.rb:123:in `platform'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/extras/command_wrapper.rb:190:in `load'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh_connection.rb:60:in `initialize'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh.rb:291:in `new'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh.rb:291:in `create_new_connection'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh.rb:86:in `connection'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/chef-apply-0.9.2/lib/chef_apply/target_host.rb:117:in `connect!'
	... 7 more
Caused by: Net::SSH::AuthenticationFailed: Authentication failed for user <user>@mkkekkonen.fi
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/net-ssh-6.1.0/lib/net/ssh.rb:268:in `start'
	C:/chef/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/train-core-3.8.7/lib/train/transports/ssh_connection.rb:213:in `establish_connection'
	... 28 more
@i5pranay93
Copy link
Contributor

i5pranay93 commented Mar 22, 2022

@mkkekkonen seems like something is wrong at your end , maybe check if it correct .pem, or username ,
I tried it on aws ubuntu machine with success
Here is command that works
chef-run ssh://ubuntu@ip-address-i ~/Downloads/mytest.pem recipes/default.rb
also this
chef-run ubuntu@ip-address -i ~/Downloads/mytest.pem recipes/default.rb

result

[✔] Packaging cookbook... done!
[✔] Generating local policyfile... exporting... done!
[✔] Applying chef-run-issue::default from /Users/prsingh/Documents/try-issue/chef-run-issue to target.
└── [✔] [ip-address] Successfully converged chef-run-issue::default.

Chef Version

Chef Workstation version: 22.2.802
Cookstyle version: 7.31.7
Chef Infra Client version: 17.9.52
Chef InSpec version: 4.52.9
Chef CLI version: 5.6.1
Chef Habitat version: 1.6.420
Test Kitchen version: 3.2.2

@i5pranay93 i5pranay93 added Status: Untriaged An issue that has yet to be triaged. and removed Status: Untriaged An issue that has yet to be triaged. labels Mar 22, 2022
@i5pranay93
Copy link
Contributor

i5pranay93 commented Apr 5, 2022

@mkkekkonen can we close this or does the issue still persists?

@mkkekkonen
Copy link
Author

@i5pranay93 Still persists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Untriaged An issue that has yet to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants