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-15] knife bootstrap ssh gives Train::PlatformDetectionFailed error if --connection-user is not provided. #8550

Closed
Vasu1105 opened this issue May 15, 2019 · 7 comments
Assignees

Comments

@Vasu1105
Copy link
Collaborator

Description

knife bootstrap with ssh gives the Train::PlatformDetectionFailed error if --connection-user is not provided. It should give valid error message which will help user to understand the root cause.

Chef Version

15.0.293

Platform Version

Ubuntu 18.04

Replication Case

I am running below command.

knife bootstrap <ip-address> -N vj-test-ssh -c ~/workspace/chef-repo/.chef/knife.rb --ssh-identity-file ~/.ssh/id_rsa --sudo -VV --yes

Client Output


Stacktrace

knife bootstrap <ip-address> -N vj-test-ssh -c ~/workspace/chef-repo/.chef/knife.rb --ssh-identity-file ~/.ssh/id_rsa --sudo -VV --yes
INFO: Using configuration from /home/msys/workspace/chef-repo/.chef/knife.rb
DEBUG: Checking if we need to accept Chef license to bootstrap node
DEBUG: Reading products and relationships...
DEBUG: Successfully read products and relationships
DEBUG: License acceptance required for chef version: 15
DEBUG: Searching for the following licenses: ["infra-client", "inspec"]
DEBUG: Found license chef_infra_client at /home/msys/.chef/accepted_licenses/chef_infra_client
DEBUG: Found license inspec at /home/msys/.chef/accepted_licenses/inspec
DEBUG: Missing licenses remaining: []
DEBUG: All licenses present
Creating new client for vj-test-ssh
Creating new node for vj-test-ssh
Connecting to <ip-address>
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:always}> (cmd.exe /c ver)
DEBUG: [SSH] opening connection to root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:always}>
The authenticity of host '<ip-address> ()' can't be established.
fingerprint is SHA256:1yVq68GEWsQiYJXgvS4fKQdJBmAEZfsdfsSWRfdsfsdf5DdSw.
Connecting to <ip-address>
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (cmd.exe /c ver)
DEBUG: [SSH] opening connection to root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}>
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (uname -s)
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (uname -m)
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (test -f /usr/bin/FastCli)
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (FastCli -p 15 -c "show version | json")
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (show version | json)
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (show version)
DEBUG: [SSH] root@<ip-address><{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["/home/msys/.ssh/id_rsa"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (version)
Traceback (most recent call last):
	20: from /usr/bin/knife:154:in `<main>'
	19: from /usr/bin/knife:154:in `load'
	18: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/bin/knife:24:in `<top (required)>'
	17: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/application/knife.rb:162:in `run'
	16: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife.rb:221:in `run'
	15: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife.rb:473:in `run_with_pretty_exceptions'
	14: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/local_mode.rb:41:in `with_server_connectivity'
	13: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife.rb:474:in `block in run_with_pretty_exceptions'
	12: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap.rb:548:in `run'
	11: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap.rb:598:in `connect!'
	10: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap.rb:647:in `do_connect'
	 9: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap/train_connector.rb:69:in `connect!'
	 8: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap/train_connector.rb:56:in `connection'
	 7: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh.rb:82:in `connection'
	 6: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh.rb:238:in `create_new_connection'
	 5: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh.rb:238:in `new'
	 4: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh_connection.rb:53:in `initialize'
	 3: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/extras/command_wrapper.rb:165:in `load'
	 2: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/plugins/base_connection.rb:110:in `platform'
	 1: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect.rb:9:in `scan'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/scanner.rb:41:in `scan': Sorry, we are unable to detect your platform (Train::PlatformDetectionFailed)
@Vasu1105 Vasu1105 added the Status: Untriaged An issue that has yet to be triaged. label May 15, 2019
@tas50 tas50 added Triage: Confirmed Indicates and issue has been confirmed as described. Status: Untriaged An issue that has yet to be triaged. and removed Status: Untriaged An issue that has yet to be triaged. Triage: Confirmed Indicates and issue has been confirmed as described. labels May 17, 2019
@kvivek1115
Copy link
Contributor

@Vasu1105 I tried to reproduce the issue but seems it is working as expected in latest chef infra 15.0.301 build.

Also with build 15.0.253 it working as expected. please have a look at logs:

knife bootstrap chef-node2.test -N vj-test-ssh -c ~/.chef/config.rb --ssh-identity-file ~/.ssh/private_key --sudo -VV --yes
WARN: [SSH] connection failed, terminating (#<Net::SSH::AuthenticationFailed: Authentication failed for user root@chef-node2.test>)
Traceback (most recent call last):
	33: from /usr/bin/knife:154:in `<main>'
	32: from /usr/bin/knife:154:in `load'
	31: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/bin/knife:24:in `<top (required)>'
	30: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/application/knife.rb:162:in `run'
	29: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife.rb:221:in `run'
	28: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife.rb:473:in `run_with_pretty_exceptions'
	27: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/local_mode.rb:41:in `with_server_connectivity'
	26: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife.rb:474:in `block in run_with_pretty_exceptions'
	25: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap.rb:548:in `run'
	24: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap.rb:598:in `connect!'
	23: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap.rb:647:in `do_connect'
	22: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap/train_connector.rb:69:in `connect!'
	21: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.0.293/lib/chef/knife/bootstrap/train_connector.rb:56:in `connection'
	20: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh.rb:82:in `connection'
	19: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh.rb:238:in `create_new_connection'
	18: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh.rb:238:in `new'
	17: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh_connection.rb:53:in `initialize'
	16: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/extras/command_wrapper.rb:165:in `load'
	15: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/plugins/base_connection.rb:110:in `platform'
	14: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect.rb:9:in `scan'
	13: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/scanner.rb:27:in `scan'
	12: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/scanner.rb:27:in `each'
	11: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/scanner.rb:33:in `block in scan'
	10: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/scanner.rb:45:in `scan_children'
	 9: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/scanner.rb:45:in `each'
	 8: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/scanner.rb:46:in `block in scan_children'
	 7: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/scanner.rb:46:in `instance_eval'
	 6: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/specifications/os.rb:29:in `block in load'
	 5: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/platforms/detect/helpers/os_windows.rb:7:in `detect_windows'
	 4: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/plugins/base_connection.rb:122:in `run_command'
	 3: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh_connection.rb:216:in `run_command_via_connection'
	 2: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh_connection.rb:247:in `session'
	 1: from /opt/chef/embedded/lib/ruby/gems/2.6.0/gems/train-core-2.1.0/lib/train/transports/ssh_connection.rb:178:in `establish_connection'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/net-ssh-5.2.0/lib/net/ssh.rb:263:in `start': Authentication failed for user root@chef-node2.test (Net::SSH::AuthenticationFailed)

@Vasu1105
Copy link
Collaborator Author

Vasu1105 commented May 20, 2019

@vsingh-msys I verified it with 15.0.300 and not yet released version 15.0.301 issue still exist for me.

@Vasu1105
Copy link
Collaborator Author

What I see the problem here it behaves differently for the same scenarios. What I debug and understood is if --connection-user is not provided it uses root user to ssh the system. And it fails where login with root user is not enabled. The weird thing it gives different error for @vsingh-msys.

@Vasu1105
Copy link
Collaborator Author

Vasu1105 commented May 21, 2019

In Chef-14 it notifies user to use the specific login user rather than error out.

$ knife bootstrap <ip-address> -N vj-test-ssh -c ~/workspace/chef-repo/.chef/knife.rb --ssh-identity-file ~/.ssh/id_rsa --sudo -VV --yes
INFO: Using configuration from /home/msys/workspace/chef-repo/.chef/knife.rb
Creating new client for vj-test-ssh
Creating new node for vj-test-ssh
Connecting to <ip-address>
DEBUG: Adding <ip-address>
<ip-address> Please login as the user "azure" rather than the user "root".
<ip-address> 

@btm
Copy link
Contributor

btm commented May 30, 2019

I accidentally reproduced this testing knife-ec2 without passing -x ubuntu.

notice we are connecting as root but the ec2 ubuntu images have ubuntu as the administrator login.

DEBUG: [SSH] root@ec2-18-215-254-31.compute-1.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>nil, :keys=>[], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:accept_new}> (version)
Traceback (most recent call last):
	23: from /home/btm/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `<main>'
	22: from /home/btm/.rvm/gems/ruby-2.5.3/bin/ruby_executable_hooks:24:in `eval'
	21: from /home/btm/.rvm/gems/ruby-2.5.3/bin/knife:23:in `<main>'
	20: from /home/btm/.rvm/gems/ruby-2.5.3/bin/knife:23:in `load'
	19: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/bin/knife:24:in `<top (required)>'
	18: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/application/knife.rb:162:in `run'
	17: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife.rb:221:in `run'
	16: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife.rb:473:in `run_with_pretty_exceptions'
	15: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/local_mode.rb:41:in `with_server_connectivity'
	14: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife.rb:474:in `block in run_with_pretty_exceptions'
	13: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:547:in `run'
	12: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:594:in `connect!'
	11: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:618:in `rescue in connect!'
	10: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife/bootstrap.rb:650:in `do_connect'
	 9: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife/bootstrap/train_connector.rb:69:in `connect!'
	 8: from /home/btm/.rvm/gems/ruby-2.5.3/gems/chef-15.0.300/lib/chef/knife/bootstrap/train_connector.rb:56:in `connection'
	 7: from /home/btm/.rvm/gems/ruby-2.5.3/gems/train-core-2.1.2/lib/train/transports/ssh.rb:82:in `connection'
	 6: from /home/btm/.rvm/gems/ruby-2.5.3/gems/train-core-2.1.2/lib/train/transports/ssh.rb:238:in `create_new_connection'
	 5: from /home/btm/.rvm/gems/ruby-2.5.3/gems/train-core-2.1.2/lib/train/transports/ssh.rb:238:in `new'
	 4: from /home/btm/.rvm/gems/ruby-2.5.3/gems/train-core-2.1.2/lib/train/transports/ssh_connection.rb:53:in `initialize'
	 3: from /home/btm/.rvm/gems/ruby-2.5.3/gems/train-core-2.1.2/lib/train/extras/command_wrapper.rb:165:in `load'
	 2: from /home/btm/.rvm/gems/ruby-2.5.3/gems/train-core-2.1.2/lib/train/plugins/base_connection.rb:110:in `platform'
	 1: from /home/btm/.rvm/gems/ruby-2.5.3/gems/train-core-2.1.2/lib/train/platforms/detect.rb:9:in `scan'
/home/btm/.rvm/gems/ruby-2.5.3/gems/train-core-2.1.2/lib/train/platforms/detect/scanner.rb:41:in `scan': Sorry, we are unable to detect your platform (Train::PlatformDetectionFailed)

@Vasu1105
Copy link
Collaborator Author

Fix is merge so closing this.

@lock
Copy link

lock bot commented Sep 3, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 3, 2019
@lamont-granquist lamont-granquist removed the Status: Untriaged An issue that has yet to be triaged. label Jun 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants