Forum: Ruby on Rails Weird problem with Net/SSH

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
426d8be2204a36c4e609ace097d7c554?d=identicon&s=25 Ohad Lutzky (ohad)
on 2007-05-01 14:37
Hi guys,

One of my applications uses SSH to authenticate the user. That is, in
order to log in to the system, the user inputs a username and password,
and the server checks those against itself using SSH. I do it like this:


  def try_to_login
    return false if self.password.nil?

      Net::SSH.start(AUTH_SERVER, self.username, self.password) {}
    rescue Net::SSH::AuthenticationFailed
      return false

    return true

Now, this works perfectly well on one server. I'm now migrating the
application to a different server. On the new server, that works
perfectly well from the commandline (Net::SSH.start raises
AuthenticationFailed if the password is wrong, and raises nothing
otherwise). However, when I try to run it within rails, or using the
model directly from script/console, I get this:

>> u =
>> u.username = 'ohad'
>> u.password = 'password' # I get the same effect with my correct password
>> u.try_to_login

Net::SSH::Exception: could not settle on kex algorithm
        from /usr/lib/ruby/1.8/net/ssh/transport/session.rb:122:in
        from /usr/lib/ruby/1.8/net/ssh/transport/session.rb:94:in
        from /usr/lib/ruby/1.8/net/ssh/transport/services.rb:121:in
        from /usr/lib/ruby/1.8/needle/lifecycle/singleton.rb:42:in
        from /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
        from /usr/lib/ruby/1.8/net/ssh/session.rb:94:in `initialize'
        from /usr/lib/ruby/1.8/net/ssh.rb:47:in `start'
        from ./script/../config/../config/../app/models/user.rb:17:in

Threading issues, perhaps? Any ideas at all? (Perhaps a different way to
check the username and password? The server authenticates through
winbind, so I can't use the shadow-file - but if there's another good
way to check u/n and p/w... though I really like SSH for this because it
allows me to authenticate against a remote server)
426d8be2204a36c4e609ace097d7c554?d=identicon&s=25 Ohad Lutzky (ohad)
on 2007-05-02 11:06
Nevermind, this is solved in the latest version.
This topic is locked and can not be replied to.