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

correctly parse "+" in config files #314

Closed
RyanJarv opened this issue Feb 28, 2016 · 3 comments
Closed

correctly parse "+" in config files #314

RyanJarv opened this issue Feb 28, 2016 · 3 comments

Comments

@RyanJarv
Copy link

Running the following with "HostkeyAlgorithms +ssh-dss" set in ~/.ssh/config will result in a "Net::SSH::Exception: could not settle on host_key algorithm" error when connecting to an ubuntu14.04 instance (haven't tested against any other nodes).

Net::SSH.start('1.2.3.4', 'ubuntu', {:timeout=>10, :auth_methods=>["publickey"], :keys_only=>true, :host_key_alias=>"host_key_alias", :key_data=> ["ssh_private_key"]})

This is only an issue with net-ssh version 3.0.2, when using 2.9.2 or using OpenSSH I am able to connect without issue. Removing the "HostkeyAlgorithms +ssh-dss" from my ssh config also fixes the issue as long as you are using a rsa key, dss is deprecated on newer versions of OpenSSH which makes this line necessary in some cases.

@mfazekas
Copy link
Collaborator

Can you please add a :verbose=>:debug and post log?

@RyanJarv
Copy link
Author

Yep, here you go.

irb(main):006:0> Net::SSH.start('host.name', 'user', {:timeout=>10, :auth_methods=>["publickey"], :keys_only=>true, :host_key_alias=>"host_key_alias", :key_data=> ["ssh_private_key"], :verbose => :debug})
D, [2016-02-28T16:44:27.680672 #64621] DEBUG -- net.ssh.transport.session[3fc4ca1480ec]: establishing connection to host.name:22
D, [2016-02-28T16:44:27.917419 #64621] DEBUG -- net.ssh.transport.session[3fc4ca1480ec]: connection established
I, [2016-02-28T16:44:27.917546 #64621]  INFO -- net.ssh.transport.server_version[3fc4ca145694]: negotiating protocol version
D, [2016-02-28T16:44:28.010825 #64621] DEBUG -- net.ssh.transport.server_version[3fc4ca145694]: remote is `SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3'
D, [2016-02-28T16:44:28.010926 #64621] DEBUG -- net.ssh.transport.server_version[3fc4ca145694]: local is `SSH-2.0-Ruby/Net::SSH_3.0.2 x86_64-darwin12.0'
W, [2016-02-28T16:44:28.011104 #64621]  WARN -- net.ssh.transport.algorithms[3fc4ca144104]: unsupported host_key algorithm: `["+ssh-dss"]'
D, [2016-02-28T16:44:28.094146 #64621] DEBUG -- socket[3fc4ca145ce8]: read 1240 bytes
D, [2016-02-28T16:44:28.094236 #64621] DEBUG -- socket[3fc4ca145ce8]: received packet nr 0 type 20 len 1236
I, [2016-02-28T16:44:28.094268 #64621]  INFO -- net.ssh.transport.algorithms[3fc4ca144104]: got KEXINIT from server
I, [2016-02-28T16:44:28.094351 #64621]  INFO -- net.ssh.transport.algorithms[3fc4ca144104]: sending KEXINIT
D, [2016-02-28T16:44:28.094441 #64621] DEBUG -- socket[3fc4ca145ce8]: queueing packet nr 0 type 20 len 1548
D, [2016-02-28T16:44:28.094492 #64621] DEBUG -- socket[3fc4ca145ce8]: sent 1552 bytes
I, [2016-02-28T16:44:28.094512 #64621]  INFO -- net.ssh.transport.algorithms[3fc4ca144104]: negotiating algorithms
Net::SSH::Exception: could not settle on host_key algorithm
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/algorithms.rb:328:in `negotiate'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/algorithms.rb:303:in `negotiate_algorithms'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/algorithms.rb:199:in `proceed!'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/algorithms.rb:191:in `send_kexinit'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/algorithms.rb:146:in `accept_kexinit'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/session.rb:202:in `block in poll_message'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/session.rb:180:in `loop'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/session.rb:180:in `poll_message'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/session.rb:217:in `block in wait'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/session.rb:215:in `loop'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/session.rb:215:in `wait'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/transport/session.rb:87:in `initialize'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh.rb:225:in `new'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh.rb:225:in `start'
    from (irb):6
    from /opt/chefdk/embedded/bin/irb:11:in `<main>'

@mfazekas
Copy link
Collaborator

mfazekas commented Mar 5, 2016

The issue is that we don't understand the "+" in HostkeyAlgorithms
The user-provided string may begin with '+' to indicate that it should be appended to the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants