# Net::ssh authenticationfailed every time!

**URL:** <https://www.ruby-forum.com/t/net-ssh-authenticationfailed-every-time/121203>\
**Category:** Deployment\
**Created:** [November 25, 2007, 10:00am UTC](https://www.ruby-forum.com/t/net-ssh-authenticationfailed-every-time/121203 "2007-11-25T10:00:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [November 25, 2007, 10:00am UTC](https://www.ruby-forum.com/t/net-ssh-authenticationfailed-every-time/121203/1 "2007-11-25T10:00:12Z")

</div>

hi, got a real serious issue with net::ssh again,

I’ve bought a new slice from slicehost running Ubuntu Gutsy 7.10, and  
i’ve setup ssh to work fine via…

scp ~/.ssh/id\_rsa.pub root@myipaddress:~/

once copied to the server, i move it into the .ssh directory disconnect  
and try ssh from my local machine, all fine

now when i try to connect via capistrano, to make it use the new server  
it keeps popping up with…

Net::SSH::AuthenticationFailed: indiehead  
from  
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh/session.rb:143:in  
`initialize' from /usr/local/lib/ruby/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh.rb:47:in `new’  
from  
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh.rb:47:in  
`start’  
from ssh.rb:6

I’m trying…

require ‘rubygems’  
require ‘net/ssh’  
include Net  
domain = ‘[mydomain.com](http://mydomain.com)’ # insert IP address or domain name here  
begin  
Net::SSH.start( domain ) do |ssh|

# …

end  
rescue Net::SSH::HostKeyMismatch =\> e  
puts “remembering new key: #{e.fingerprint}”  
e.remember\_host!  
retry  
end

which usually works but this time it doesn’t want to know, any ideas?

i’m using port 22 so nothing’s out of the ordinary, the app is on  
another box so i’m trying to migrate it to the new slice.

appreciate any help with this, tried for hours yesterday, got nowhere.

John.

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [November 25, 2007, 6:58pm UTC](https://www.ruby-forum.com/t/net-ssh-authenticationfailed-every-time/121203/2 "2007-11-25T18:58:23Z")

</div>

Hello John,  
You made your key to connect to root@myipaddress but forgot the  
username in your script so it is attempting to connect to  
indiehead@myipaddress instead.

You can specify the username as the second parameter to the Net:SSH  
call.

Net::SSH.start( domain, ‘root’ ) do |ssh|

Likewise in your actual capistrano recipe, you would want to add:  
set :user, ‘root’

Shawn Balestracci

On Nov 25, 2007 1:00 AM, John G.

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [November 26, 2007, 12:26pm UTC](https://www.ruby-forum.com/t/net-ssh-authenticationfailed-every-time/121203/3 "2007-11-26T12:26:25Z")

</div>

Shawn Balestracci wrote:

> Hello John,  
> You made your key to connect to root@myipaddress but forgot the  
> username in your script so it is attempting to connect to  
> indiehead@myipaddress instead.
> 
> You can specify the username as the second parameter to the Net:SSH  
> call.
> 
> Net::SSH.start( domain, ‘root’ ) do |ssh|
> 
> Likewise in your actual capistrano recipe, you would want to add:  
> set :user, ‘root’
> 
> Shawn Balestracci
> 
> On Nov 25, 2007 1:00 AM, John G.

excellent, will try this when i get back home tonight, driving me nuts!

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [May 18, 2010, 1:28pm UTC](https://www.ruby-forum.com/t/net-ssh-authenticationfailed-every-time/121203/4 "2010-05-18T13:28:23Z")

</div>

John G. wrote:

> Shawn Balestracci wrote:
> 
> > Hello John,  
> > You made your key to connect to root@myipaddress but forgot the  
> > username in your script so it is attempting to connect to  
> > indiehead@myipaddress instead.
> > 
> > You can specify the username as the second parameter to the Net:SSH  
> > call.
> > 
> > Net::SSH.start( domain, ‘root’ ) do |ssh|
> > 
> > Likewise in your actual capistrano recipe, you would want to add:  
> > set :user, ‘root’
> > 
> > Shawn Balestracci
> > 
> > On Nov 25, 2007 1:00 AM, John G.
> 
> excellent, will try this when i get back home tonight, driving me nuts!

Shawn,  
I was wondering, if you got that to work, since i am also having the  
same issue  
Thanks,  
-Kamal.
