Sha256: 9625a1e80a93db4f31f6259f34088da06c467657a0e270eeed1ab1b4e7a74712

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

module VagrantPlugins
  module Unison
    class SshCommand
      def initialize(machine)
        @machine = machine
      end

      def ssh
        %W(
          ssh
          #{@machine.config.unison.ssh_user}@#{@machine.config.unison.ssh_host}
          #{ssh_args}
        ).compact.join(' ')
      end

      def ssh_args
        %W(
          -p #{@machine.config.unison.ssh_port}
          #{proxy_command}
          -o StrictHostKeyChecking=no
          -o UserKnownHostsFile=/dev/null
          #{key_paths}
        ).compact.join(' ')
      end

      def uri(unison_paths)
        username = @machine.config.unison.ssh_user
        host = @machine.config.unison.ssh_host

        "ssh://#{username}@#{host}/#{unison_paths.guest}"
      end

      private

      def proxy_command
        command = @machine.ssh_info[:proxy_command]
        return nil unless command
        "-o ProxyCommand='#{command}'"
      end

      def key_paths
        @machine.ssh_info[:private_key_path].map { |p| "-i #{p}" }.join(' ')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-unison2-1.2.3 lib/vagrant-unison2/ssh_command.rb
vagrant-unison2-1.2.2 lib/vagrant-unison2/ssh_command.rb