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

SSH Authentication Failed on Centos8 AMI #529

Closed
ssok1 opened this issue Jan 11, 2021 · 1 comment
Closed

SSH Authentication Failed on Centos8 AMI #529

ssok1 opened this issue Jan 11, 2021 · 1 comment

Comments

@ssok1
Copy link

ssok1 commented Jan 11, 2021

kitchen.yml:


driver:
name: ec2
aws_ssh_key_id: <%= ENV['AWS_SSH_KEYNAME'] %>
region: us-east-1
instance_type: <%= ENV['AWS_INSTANCE_TYPE'] %>
spot_price: <%= ENV['AWS_SPOT_PRICE'] %>
associate_public_ip: false
interface: private
subnet_id: <%= ENV['AWS_SUBNET_ID'] %>
security_group_ids: <%= ENV['AWS_SG_ID'] %>
retryable_tries: 200
shared_credentials_profile: saml
user_data: user_data_centos_8.sh

provisioner:
name: shell
log_level: 5
max_retries: 3
wait_for_retry: 30
retry_on_exit_code: # will retry if winrm is unable to connect to the ec2 instance
- -1 #Generic error during Chef execution
- 1 #Generic error during Chef execution

verifier:
name: inspec
format: documentation
reporter:
- cli
- html:./inspec_output.html

transport:
name: ssh
ssh_key: ~/.ssh/<%= ENV['AWS_SSH_KEYNAME'] %>.pem
max_wait_until_ready: 900
connect_timeout: 60
connection_retries: 10
connection_retry_sleep: 10
username: centos

platforms:

  • name: centos-8
    driver:
    image_id: <%= ENV['AWS_AMI_ID'] %>

suites:

  • name: default
    verifier:
    inspec_tests:
    - test/os_spec.rb

SSH refused then fails:

[SSH] opening connection to user@##.###.##.##<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :keepalive_maxcount=>3, :timeout=>15, :keys_only=>true, :keys=>["/root/.ssh/####.pem"], :auth_methods=>["publickey"], :verify_host_key=>:never, :logger=>#<Logger:0x0000000003aeb1d8 @Level=4, @progname=nil, @default_formatter=#<Logger::Formatter:0x0000000003aeb138 @datetime_format=nil>, @Formatter=nil, @logdev=#<Logger::LogDevice:0x0000000003aeb0e8 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:>, @mon_mutex=#Thread::Mutex:0x0000000003aeb020, @mon_mutex_owner_object_id=30890100, @mon_owner=nil, @mon_count=0>>, :password_prompt=>#Net::SSH::Prompt:0x0000000003aeafa8, :user=>"user"}>

[SSH] connection failed (#<Errno::ECONNREFUSED: Connection refused - connect(2) for ##.###.##.##:22>)
Waiting for SSH service on ##.###.##.##:22, retrying in 3 seconds
[SSH] opening connection to user@##.###.##.##<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :keepalive_maxcount=>3, :timeout=>15, :keys_only=>true, :keys=>["/root/.ssh/####.pem"], :auth_methods=>["publickey"], :verify_host_key=>:never, :logger=>#<Logger:0x0000000003aeb1d8 @Level=4, @progname=nil, @default_formatter=#<Logger::Formatter:0x0000000003aeb138 @datetime_format=nil>, @Formatter=nil, @logdev=#<Logger::LogDevice:0x0000000003aeb0e8 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:>, @mon_mutex=#Thread::Mutex:0x0000000003aeb020, @mon_mutex_owner_object_id=30890100, @mon_owner=nil, @mon_count=0>>, :password_prompt=>#Net::SSH::Prompt:0x0000000003aeafa8, :user=>"user"}>
[SSH] connection failed (#<Net::SSH::AuthenticationFailed: Authentication failed for user user@##.###.##.##>)

When attempting to SSH manually with the same key it works.

@lmayorga1980
Copy link

related to #398

@ssok1 ssok1 closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants