Commit 3abf9d97 authored by Seth Chisamore's avatar Seth Chisamore Committed by Daniel DeLeo
Browse files

[CHEF-1768] knife commands that use ssh should allow the port to be configured

parent 85382cc7
......@@ -96,7 +96,6 @@ class Chef::Application::Knife < Chef::Application
:description => "Accept default values for all questions"
option :print_after,
:short => "-p",
:long => "--print-after",
:description => "Show the data after a destructive operation"
......
......@@ -38,6 +38,13 @@ class Chef
:long => "--ssh-password PASSWORD",
:description => "The ssh password"
option :ssh_port,
:short => "-p PORT",
:long => "--ssh-port PORT",
:description => "The ssh port",
:default => "22",
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
option :identity_file,
:short => "-i IDENTITY_FILE",
:long => "--identity-file IDENTITY_FILE",
......@@ -149,6 +156,7 @@ class Chef
ssh.name_args = [ server_name, ssh_command ]
ssh.config[:ssh_user] = config[:ssh_user]
ssh.config[:ssh_password] = config[:ssh_password]
ssh.config[:ssh_port] = Chef::Config[:knife][:ssh_port] || config[:ssh_port]
ssh.config[:identity_file] = config[:identity_file]
ssh.config[:manual] = true
ssh
......
......@@ -62,6 +62,13 @@ class Chef
:long => "--ssh-password PASSWORD",
:description => "The ssh password"
option :ssh_port,
:short => "-p PORT",
:long => "--ssh-port PORT",
:description => "The ssh port",
:default => "22",
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
option :identity_file,
:short => "-i IDENTITY_FILE",
:long => "--identity-file IDENTITY_FILE",
......@@ -113,6 +120,7 @@ class Chef
session_opts = {}
session_opts[:keys] = File.expand_path(config[:identity_file]) if config[:identity_file]
session_opts[:password] = config[:ssh_password] if config[:ssh_password]
session_opts[:port] = Chef::Config[:knife][:ssh_port] || config[:ssh_port]
session_opts[:logger] = Chef::Log.logger if Chef::Log.level == :debug
session.use(hostspec, session_opts)
......
......@@ -68,6 +68,7 @@ describe Chef::Knife::Bootstrap do
@knife.name_args = ["foo.example.com"]
@knife.config[:ssh_user] = "rooty"
@knife.config[:ssh_password] = "open_sesame"
Chef::Config[:knife][:ssh_port] = "4001"
@knife.config[:identity_file] = "~/.ssh/me.rsa"
@knife_ssh = @knife.knife_ssh
end
......@@ -84,6 +85,10 @@ describe Chef::Knife::Bootstrap do
@knife_ssh.config[:ssh_password].should == 'open_sesame'
end
it "configures the ssh port" do
@knife_ssh.config[:ssh_port].should == '4001'
end
it "configures the ssh identity file" do
@knife_ssh.config[:identity_file].should == '~/.ssh/me.rsa'
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment