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:
AUTH_SERVER = ‘127.0.0.1’
def try_to_login
return false if self.password.nil?
begin
Net::SSH.start(AUTH_SERVER, self.username, self.password) {}
rescue Net::SSH::AuthenticationFailed
return false
end
finalize_login
return true
end
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 = User.new()
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/algorithm-negotiator.rb:156:in
negotiate' from /usr/lib/ruby/1.8/net/ssh/transport/session.rb:122:in
kexinit’
from /usr/lib/ruby/1.8/net/ssh/transport/session.rb:94:in
initialize' from /usr/lib/ruby/1.8/net/ssh/transport/services.rb:121:in
register_services’
from /usr/lib/ruby/1.8/needle/lifecycle/singleton.rb:42:in
call' from /usr/lib/ruby/1.8/thread.rb:135:in
synchronize’
snip
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
`try_to_login’
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)