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

Open
Vasu1105 opened this issue May 15, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@Vasu1105
Copy link
Contributor

commented May 15, 2019

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)
@vsingh-msys

This comment has been minimized.

Copy link
Contributor

commented May 20, 2019

@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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

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

This comment has been minimized.

Copy link
Contributor Author

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> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.