Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove explicit SSH Port 22 to allow ssh configuration files to overw…

…rite it.
  • Loading branch information...
commit babc48a04c799d21145f843080c57b91119fbae9 1 parent a6223b3
Ben Lavender authored jamis committed
View
2  CHANGELOG
@@ -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]
View
10 lib/capistrano/ssh.rb
@@ -23,9 +23,6 @@ def self.apply_to(connection, server)
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 @@ def self.connection_strategy(server, options={}, &block)
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
View
4 test/configuration/connections_test.rb
@@ -60,7 +60,7 @@ def test_default_connection_factory_honors_config_options
def test_connection_factory_should_return_gateway_instance_if_gateway_variable_is_set
@config.values[:gateway] = "j@capistrano"
- Net::SSH::Gateway.expects(:new).with("capistrano", "j", :port => 22, :password => nil, :auth_methods => %w(publickey hostbased)).returns(stub_everything)
+ Net::SSH::Gateway.expects(:new).with("capistrano", "j", :password => nil, :auth_methods => %w(publickey hostbased)).returns(stub_everything)
assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory
end
@@ -324,4 +324,4 @@ def mock_task(options={})
:max_hosts => options[:max_hosts]
)
end
-end
+end
View
1  test/ssh_test.rb
@@ -5,7 +5,6 @@ class SSHTest < Test::Unit::TestCase
def setup
Capistrano::ServerDefinition.stubs(:default_user).returns("default-user")
@options = { :password => nil,
- :port => 22,
:auth_methods => %w(publickey hostbased) }
@server = server("capistrano")
end
Please sign in to comment.
Something went wrong with that request. Please try again.