# AuthenticationFailed error with Net::SSH::Gateway

**URL:** <https://www.ruby-forum.com/t/authenticationfailed-error-with-net-gateway/167232>\
**Category:** Ruby\
**Created:** [May 5, 2009, 7:50pm UTC](https://www.ruby-forum.com/t/authenticationfailed-error-with-net-gateway/167232 "2009-05-05T19:50:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joemanfoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4bbf92/32.png) [@joemanfoo](https://www.ruby-forum.com/u/joemanfoo)\
**Post date:** [May 5, 2009, 7:50pm UTC](https://www.ruby-forum.com/t/authenticationfailed-error-with-net-gateway/167232/1 "2009-05-05T19:50:41Z")

</div>

Hello  
I wrote up a script that will connect to a remote Linux system and run  
some commands. Now I need to use the Net::SSH::Gateway gem to connect  
to a host, and use that as a portal to SSH to another system.

Normally, I can connect to the first box and SSH successfully to  
another.

However, when I try to use Net::SSH::Gateway, I get an  
AuthenticationFailed error. I’m completely lost because my credentials  
are correct.

Here is my test code, which is nearly the same example code found in the  
Net::SSH::Gateway API:

* * *

require ‘net/ssh’  
require ‘net/ssh/gateway’

gateway = Net::SSH::Gateway.new(‘sytem1’, ‘joe’, :password =\>  
‘password’)

gateway.ssh(‘system2’, ‘joe’) do |ssh|  
puts ssh.exec!(“uname -n”)  
end

gateway.shutdown!

* * *

## D:/Program Files/Ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.11/lib/net/ssh.rb:192:in `start': joe (Net::SSH::AuthenticationFailed) from D:/Program Files/Ruby/lib/ruby/gems/1.8/gems/net-ssh-gateway-1.0.1/lib/net/ssh/gateway.rb:169:in`ssh’ from Playground.rb:12

If it helps, I’m using the following:  
Ruby (1.8.6)  
net-ssh gem (2.0.11)  
net-ssh-gateway (1.0.1)

---

<div class="post-metadata">

**Author:** ![joemanfoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4bbf92/32.png) [@joemanfoo](https://www.ruby-forum.com/u/joemanfoo)\
**Post date:** [May 11, 2009, 4:49pm UTC](https://www.ruby-forum.com/t/authenticationfailed-error-with-net-gateway/167232/2 "2009-05-11T16:49:07Z")

</div>

Just to follow up, I examined the logs on my target linux boxes and it  
seems that authentication is indeed successful. What I found odd was  
that the logs on the target system (system2 in my code) said the  
connection was closed by system1 (the gateway), which in turn said the  
connection was closed by my local workstation.

☹
