<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 *unreleased*
 
+* Let Net::SSH manage the default SSH port selection [Ben Lavender]
+
 * Changed capture() helper to not raise an exception on error, but to warn instead [Jeff Forcier]
 
 </diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -23,9 +23,6 @@ module Capistrano
       attr_accessor :xserver
     end
 
-    # The default port for SSH.
-    DEFAULT_PORT = 22
-
     # An abstraction to make it possible to connect to the server via public key
     # without prompting for the password. If the public key authentication fails
     # this will fall back to password authentication.
@@ -58,10 +55,11 @@ module Capistrano
       methods = [ %w(publickey hostbased), %w(password keyboard-interactive) ]
       password_value = nil
 
-      ssh_options        = (server.options[:ssh_options] || {}).merge(options[:ssh_options] || {})
-      user               = server.user || options[:user] || ssh_options[:username] || ServerDefinition.default_user
-      ssh_options[:port] = server.port || options[:port] || ssh_options[:port] || DEFAULT_PORT
+      ssh_options = (server.options[:ssh_options] || {}).merge(options[:ssh_options] || {})
+      user        = server.user || options[:user] || ssh_options[:username] || ServerDefinition.default_user
+      port        = server.port || options[:port] || ssh_options[:port]
 
+      ssh_options[:port] = port if port
       ssh_options.delete(:username)
 
       begin</diff>
      <filename>lib/capistrano/ssh.rb</filename>
    </modified>
    <modified>
      <diff>@@ -60,7 +60,7 @@ class ConfigurationConnectionsTest &lt; Test::Unit::TestCase
 
   def test_connection_factory_should_return_gateway_instance_if_gateway_variable_is_set
     @config.values[:gateway] = &quot;j@capistrano&quot;
-    Net::SSH::Gateway.expects(:new).with(&quot;capistrano&quot;, &quot;j&quot;, :port =&gt; 22, :password =&gt; nil, :auth_methods =&gt; %w(publickey hostbased)).returns(stub_everything)
+    Net::SSH::Gateway.expects(:new).with(&quot;capistrano&quot;, &quot;j&quot;, :password =&gt; nil, :auth_methods =&gt; %w(publickey hostbased)).returns(stub_everything)
     assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory
   end
 
@@ -324,4 +324,4 @@ class ConfigurationConnectionsTest &lt; Test::Unit::TestCase
         :max_hosts =&gt; options[:max_hosts]
       )
     end
-end
\ No newline at end of file
+end</diff>
      <filename>test/configuration/connections_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,6 @@ class SSHTest &lt; Test::Unit::TestCase
   def setup
     Capistrano::ServerDefinition.stubs(:default_user).returns(&quot;default-user&quot;)
     @options = { :password =&gt; nil,
-                 :port     =&gt; 22,
                  :auth_methods =&gt; %w(publickey hostbased) }
     @server = server(&quot;capistrano&quot;)
   end</diff>
      <filename>test/ssh_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a6223b3939f0ef91c928f94502c806a68a011e74</id>
    </parent>
  </parents>
  <author>
    <name>Ben Lavender</name>
    <email>ben@ben.local</email>
  </author>
  <url>http://github.com/jamis/capistrano/commit/babc48a04c799d21145f843080c57b91119fbae9</url>
  <id>babc48a04c799d21145f843080c57b91119fbae9</id>
  <committed-date>2008-06-23T08:28:27-07:00</committed-date>
  <authored-date>2008-06-18T07:19:52-07:00</authored-date>
  <message>Remove explicit SSH Port 22 to allow ssh configuration files to overwrite it.</message>
  <tree>ffd3e82005f23960218bb6174421624aa6e76fb4</tree>
  <committer>
    <name>Jamis Buck</name>
    <email>jamis@37signals.com</email>
  </committer>
</commit>
