Skip to content

Commit

Permalink
Add option for custom ssh config
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuay03 committed Jan 22, 2024
1 parent 0b870b9 commit ef23bf9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Options:
All paths should be relative to the base sync directory.
-p, --port PORT Overwrite the SSH port (usually 22)
(doesn't do anything in slave mode)
-c, --ssh-options PATH Use a custom SSH config (usually $HOME/.ssh/config)
(doesn't do anything in slave mode)
--force-polling Forces the use of the listen polling adapter
(works cross-platform, generally slower, doesn't do anything in slave mode)
--no-rvm Skip attempting to load RVM on remote
Expand Down
4 changes: 4 additions & 0 deletions exe/entangler
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ OptionParser.new do |opts|
value_opt(options, opts, :port, '-p', '--port PORT', 'Overwrite the SSH port (usually 22)',
"(doesn't do anything in slave mode)")

value_opt(options, opts, :config, '-c', '--config PATH', 'Use a custom SSH config (usually $HOME/.ssh/config)',
"(doesn't do anything in slave mode)")

bool_opt(options, opts, :force_polling, '--force-polling',
'Forces the use of the listen polling adapter',
"(works cross-platform, generally slower, doesn't do anything in slave mode)")
Expand Down Expand Up @@ -124,6 +127,7 @@ if options[:ignore]
end
end

opts[:config] = options[:config]
opts[:force_polling] = options[:force_polling]
opts[:no_rvm] = options[:no_rvm]
opts[:quiet] = options[:quiet]
Expand Down
4 changes: 2 additions & 2 deletions lib/entangler/executor/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def generate_ssh_command(cmd, source_rvm: false)
cmd
end

"ssh -q #{remote_hostname} -p #{@opts[:remote_port]} -C \"#{prefixed_cmd}\""
"ssh -q #{remote_hostname} -p #{@opts[:remote_port]} -F #{@opts[:config]} -C \"#{prefixed_cmd}\""
end

def remote_hostname
Expand All @@ -83,7 +83,7 @@ def rsync_cmd_string(rsync_ignores_file_path)
remote_path += "#{@opts[:remote_base_dir]}/"

cmd = "rsync -azv --exclude-from #{rsync_ignores_file_path}"
cmd += " -e \"ssh -p #{@opts[:remote_port]}\"" if @opts[:remote_mode]
cmd += " -e \"ssh -p #{@opts[:remote_port]} -F #{@opts[:config]}\"" if @opts[:remote_mode]
cmd + " --delete #{base_dir}/ #{remote_path}"
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/entangler/executor/validation/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def validate_opts
super
if @opts[:remote_mode]
@opts[:remote_port] ||= '22'
@opts[:config] ||= '$HOME/.ssh/config'
validate_remote_opts
else
validate_local_opts
Expand Down
2 changes: 1 addition & 1 deletion lib/entangler/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Entangler
VERSION = '1.5.0'
VERSION = '1.5.1'
end

0 comments on commit ef23bf9

Please sign in to comment.