Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #526 from nulogy/quote_file_paths_for_ssh
Browse files Browse the repository at this point in the history
Quote file paths for ssh
  • Loading branch information
matschaffer authored Jan 3, 2018
2 parents ba6f1c9 + b01d9f8 commit b873da3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/knife-solo/ssh_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ def ssh_args

args << [user, host].compact.join('@')

args << "-F #{config[:ssh_config]}" if config[:ssh_config]
args << "-i #{identity_file}" if identity_file
args << "-F \"#{config[:ssh_config]}\"" if config[:ssh_config]
args << "-i \"#{identity_file}\"" if identity_file
args << "-o ForwardAgent=yes" if config[:forward_agent]
args << "-p #{config[:ssh_port]}" if config[:ssh_port]
args << "-o UserKnownHostsFile=#{connection_options[:user_known_hosts_file]}" if config[:host_key_verify] == false
args << "-o UserKnownHostsFile=\"#{connection_options[:user_known_hosts_file]}\"" if config[:host_key_verify] == false
args << "-o StrictHostKeyChecking=no" if config[:host_key_verify] == false
args << "-o ControlMaster=auto -o ControlPath=#{ssh_control_path} -o ControlPersist=3600" unless config[:ssh_control_master] == "no"

Expand Down
8 changes: 4 additions & 4 deletions test/ssh_command_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,23 @@ def test_builds_cli_ssh_args

cmd = command("[email protected]", "--ssh-config-file=myconfig")
cmd.validate_ssh_options!
assert_equal "[email protected] -F myconfig", cmd.ssh_args
assert_equal "[email protected] -F \"myconfig\"", cmd.ssh_args

cmd = command("[email protected]", "--ssh-identity=my_rsa")
cmd.validate_ssh_options!
assert_equal "[email protected] -i my_rsa", cmd.ssh_args
assert_equal "[email protected] -i \"my_rsa\"", cmd.ssh_args

cmd = command("[email protected]", "--identity-file=my_rsa")
cmd.validate_ssh_options!
assert_equal "[email protected] -i my_rsa", cmd.ssh_args
assert_equal "[email protected] -i \"my_rsa\"", cmd.ssh_args

cmd = command("[email protected]", "--ssh-port=222")
cmd.validate_ssh_options!
assert_equal "[email protected] -p 222", cmd.ssh_args

cmd = command("[email protected]", "--no-host-key-verify")
cmd.validate_ssh_options!
assert_equal "[email protected] -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no", cmd.ssh_args
assert_equal "[email protected] -o UserKnownHostsFile=\"/dev/null\" -o StrictHostKeyChecking=no", cmd.ssh_args

cmd = command("[email protected]", "--forward-agent")
cmd.validate_ssh_options!
Expand Down

0 comments on commit b873da3

Please sign in to comment.