# Problem with ssh -\> authentication failed

**URL:** <https://rubytalk.org/t/problem-with-ssh-authentication-failed/50115>\
**Category:** ruby-talk\
**Created:** [10 November 2008 13:08 UTC](https://rubytalk.org/t/problem-with-ssh-authentication-failed/50115 "2008-11-10T13:08:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ice\_Man](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@Ice\_Man](https://rubytalk.org/u/Ice_Man)\
**Post date:** [10 November 2008 13:08 UTC](https://rubytalk.org/t/problem-with-ssh-authentication-failed/50115/1 "2008-11-10T13:08:04Z")

</div>

Hi,

i have a very stupid and annoying problem;/ I wrote a simple script:

require 'rubygems'  
require 'net/ssh'

Net::SSH.start('host',:username =\> 'user',:password =\> 'pass') do

> session\>

shell=session.shell.open

&nbsp;&nbsp;shell.dir  
&nbsp;&nbsp;shell.exit

&nbsp;&nbsp;$stdout.print shell.stdout while shell.stdout?  
&nbsp;&nbsp;$stderr.puts "-- stderr: --"  
&nbsp;&nbsp;$stderr.print shell.stderr while shell.stderr?

&nbsp;&nbsp;end

All the time I have the same error:

c:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.4/lib/net/ssh.rb:195:in  
`start': Net::SSH::AuthenticationFailed

I tried a lot of diffrent script with ssh, but all the time I have still  
the same error

Any suggestions what's wrong ??

THX

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [10 November 2008 13:46 UTC](https://rubytalk.org/t/problem-with-ssh-authentication-failed/50115/2 "2008-11-10T13:46:18Z")

</div>

> c:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.4/lib/net/ssh.rb:195:in  
> `start': Net::SSH::AuthenticationFailed

...

> Any suggestions what's wrong ??

I apologise for stating the obvious, but it looks like a wrong username  
and/or password. Or it could be that there is something else at the  
server side which is rejecting the connection, e.g. it's possible to  
configure ssh accounts so they only accept connections from a particular  
IP address, or so that they can only run certain commands (not shells).

Looking at sshd logs on the far side could help to determine the  
problem. Even better, try running sshd in debug mode, bound to a  
different port:

&nbsp;&nbsp;&nbsp;# sshd -d -p 99

This will stay in the foreground without forking, and show you the  
processing of incoming connections. Add :port=\>99 to your client of  
course.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
