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

Detailed SSH error when creating instance #589

Open
TinNT opened this issue Mar 18, 2016 · 0 comments
Open

Detailed SSH error when creating instance #589

TinNT opened this issue Mar 18, 2016 · 0 comments

Comments

@TinNT
Copy link

TinNT commented Mar 18, 2016

Hi,

Thanks for creating this awesome gem, I have been using this gem for a few years. I thought I would share the issue that took me at least 4 hours to debug.

I upgraded the deployment script to use rubber 3.2.1, when I created the instance. It kept showing the "timeout in initial connect, retrying" error.

At this time, I thought the public/private key path, permission may not correct. I tried to ssh to the instance manually, it worked.

After a few hours of debugging, I changed the rubber source code to output the detailed error like

begin
  _ensure_key_file_present
  _allow_root_ssh
  _disable_password_based_ssh_login if cloud.should_disable_password_based_ssh_login?

  # If the initial_ssh_user is different than the deploy user, we can terminate the SSH connection
  # because from here on out we'll be connecting as the deploy user.
  if initial_ssh_user != fetch(:user, nil)
    teardown_connections_to(sessions.keys)
  end
rescue ConnectionError => e
  if e.message =~ /Net::SSH::AuthenticationFailed/
    logger.info "Can't connect as user #{initial_ssh_user} to #{ip}, assuming root allowed"
  else
    sleep 2
    error_details = "#{e.class}: #{e}"
    error_details += "\n#{e.backtrace.join("\n")}" if e.backtrace
    pp "error_details: enable_root_ssh - ", error_details, e
    logger.info "Failed to connect to #{ip}, retrying"
    retry
  end
end

It printed the error like:

"error_details: enable_root_ssh - "
"Capistrano::ConnectionError: connection failed for: ubuntu@52.58.79.47 (ArgumentError: invalid option(s): number_of_password_prompts)\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/connections.rb:134:in `establish_connections_to'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/connections.rb:195:in `block in execute_on_servers'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/connections.rb:193:in `each'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/connections.rb:193:in `each_slice'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/connections.rb:193:in `execute_on_servers'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/actions/file_transfer.rb:41:in `transfer'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/actions/file_transfer.rb:26:in `upload'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/actions/file_transfer.rb:13:in `put'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber/utils.rb:161:in `prepare_script'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber/utils.rb:174:in `sudo_script'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber/setup.rb:73:in `block in enable_root_ssh'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber.rb:54:in `call'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber.rb:54:in `block in task'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/execution.rb:138:in `instance_eval'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/execution.rb:89:in `execute_task'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/capistrano-2.15.7/lib/capistrano/configuration/namespaces.rb:110:in `block in define_task'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber/setup.rb:99:in `enable_root_ssh'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber/instances.rb:430:in `block in refresh_instance'\n
/Users/tn/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/timeout.rb:68:in `timeout'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber/instances.rb:420:in `refresh_instance'\n
/Users/tn/.rvm/gems/ruby-1.9.3-p362@myapp/gems/rubber-3.2.1/lib/rubber/recipes/rubber/instances.rb:372:in `block (2 levels) in refresh_instances'"
#<Capistrano::ConnectionError: connection failed for: ubuntu@52.58.79.47 (ArgumentError: invalid option(s): number_of_password_prompts)>
 ** Failed to connect to 1.2.3.4, retrying

I went a head to check the error, after upgrading net-ssh gem to 2.9.4 (it was 2.6.0), the deployment script ran successfully.

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

1 participant