# Capistrano doesn't know port number?

**URL:** <https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026>\
**Category:** Rails\
**Created:** [June 5, 2007, 7:40pm UTC](https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026 "2007-06-05T19:40:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshuajnoble](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@joshuajnoble](https://www.ruby-forum.com/u/joshuajnoble)\
**Post date:** [June 5, 2007, 7:40pm UTC](https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026/1 "2007-06-05T19:40:24Z")

</div>

This is a Capistrano question (sorry if those aren’t encouraged), but  
am I understanding this wrong?

[removed\_email\_address@domain.invalid] executing command  
\*\* [out :: removed\_email\_address@domain.invalid] ssh: connect to host xxx.xx.xx.xxx  
port 22: Connection refused  
\*\* [out :: removed\_email\_address@domain.invalid] svn: Connection closed unexpectedly

in my deploy.rb I have this:

ssh\_options[:keys] = %w(/Users/base/.ssh/id\_dsa)  
ssh\_options[:port] = 6666

which I assumed would tell Capistrano to use port 6666. It worked fine  
through the other tasks that I used but this one doesn’t seem to get  
it. This strikes me as pretty wierd. Any suggestions? I mean it seems  
like this is something pretty fundamentally wrong on my part.

---

<div class="post-metadata">

**Author:** ![joshuajnoble](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@joshuajnoble](https://www.ruby-forum.com/u/joshuajnoble)\
**Post date:** [June 5, 2007, 7:58pm UTC](https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026/2 "2007-06-05T19:58:26Z")

</div>

Yeah, I’m in the midst of trying to get around this, but I would think  
if this was a real problem (i.e. not implemented, vs just a  
configuration problem) more people would have noticed it. I mean, not  
being able to use any port other than 22 seems like it might be a kind  
of large piece of missing functionality, or am I one of the few people  
logging in from ports other than 22?

---

<div class="post-metadata">

**Author:** ![joshuajnoble](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@joshuajnoble](https://www.ruby-forum.com/u/joshuajnoble)\
**Post date:** [June 5, 2007, 7:47pm UTC](https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026/3 "2007-06-05T19:47:25Z")

</div>

joshuajnoble wrote:

> ssh\_options[:keys] = %w(/Users/base/.ssh/id\_dsa)  
> ssh\_options[:port] = 6666
> 
> which I assumed would tell Capistrano to use port 6666. It worked fine  
> through the other tasks that I used but this one doesn’t seem to get  
> it. This strikes me as pretty wierd. Any suggestions? I mean it seems  
> like this is something pretty fundamentally wrong on my part.

I remember struggling with something similar with Capistrano myself. I  
remember trying the suggestions of adding the server info to the .config  
file of my .ssh directory and the config file in my subversion  
directory, but it still blew up during a deploy. I meant to file a bug  
report with Jamis, but I got lazy.

I’m not in front of my linux box right now, so I can’t tell you exactly  
what my work around was, but I remember it was kind of kludgy.

HTH,

Jamey C.

---

<div class="post-metadata">

**Author:** ![joshuajnoble](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@joshuajnoble](https://www.ruby-forum.com/u/joshuajnoble)\
**Post date:** [June 5, 2007, 8:24pm UTC](https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026/4 "2007-06-05T20:24:33Z")

</div>

I gave this a try to no avail

def self.connect(server, config, port=6666, &block)  
methods = [ %w(publickey hostbased), %w(password keyboard-  
interactive) ]  
password\_value = nil

```
 user, server_stripped, pport = parse_server(server)

 begin
   ssh_options = { :username => (user || config.user),
                   :password => password_value,
         #:port => ((pport && pport != port) ? pport : port),
            :port => 6666,
            :auth_methods => methods.shift 

```

}.merge(config.ssh\_options)  
Net::SSH.start(server\_stripped,ssh\_options,&block)  
rescue Net::SSH::AuthenticationFailed  
raise if methods.empty?  
password\_value = config.password  
retry  
end  
end

But still no love, so I really don’t know where port 22 could be  
getting defined. Do I have to change my access port in order to use  
Capistrano?

---

<div class="post-metadata">

**Author:** ![joshuajnoble](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@joshuajnoble](https://www.ruby-forum.com/u/joshuajnoble)\
**Post date:** [June 6, 2007, 2:34am UTC](https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026/5 "2007-06-06T02:34:35Z")

</div>

Thanks for the tip. I noticed that when I was looking at the ssh.rb  
file. I ended up just changing my port.

---

<div class="post-metadata">

**Author:** ![joshuajnoble](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@joshuajnoble](https://www.ruby-forum.com/u/joshuajnoble)\
**Post date:** [June 6, 2007, 2:08am UTC](https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026/6 "2007-06-06T02:08:34Z")

</div>

Josh-

If you have cap 1.4.1 installed then you can set the port for each  
server in the role setting:

role :web, “65.76.159.124:6800”

Cap will just do the right thing then.

CHeers-  
-Ezra

On Jun 5, 2007, at 11:23 AM, joshuajnoble wrote:

> ```
> retry
> 
> ```
> 
> > if this was a real problem (i.e. not implemented, vs just a
> > 
> > > > This is a Capistrano question (sorry if those aren’t
> > 
> > > exactly  
> > > what my work around was, but I remember it was kind of kludgy.
> > 
> > > HTH,
> > 
> > > Jamey C.
> 
> >

– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![joshuajnoble](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@joshuajnoble](https://www.ruby-forum.com/u/joshuajnoble)\
**Post date:** [June 6, 2007, 1:22pm UTC](https://www.ruby-forum.com/t/capistrano-doesnt-know-port-number/106026/7 "2007-06-06T13:22:54Z")

</div>

Having same problems. If you find a cure other than changing port  
number. Let me know.

Cheers  
Zach I.  
â†’ Blog – [http://www.zachinglis.com](http://www.zachinglis.com)  
â†’ Company – [http://www.lt3media.com](http://www.lt3media.com)  
â†’ Portfolio – [http://portfolio.zachinglis.com](http://portfolio.zachinglis.com)  
â†’ Web Designer â†’ Print Designer â†’ Identity Desginer â†’ Ruby on  
Rails developer â†’ et plus.  
â†’ AIM: zachinglis â†’ MSN: removed\_email\_address@domain.invalid â†’ Others  
available on request
