Sha256: 61eb19fd458eed820c336a348a058e68a60e58f2e36490c54b097597cf832d37

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 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
          #{identity}
        ).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 identity
        if @machine.config.unison.ssh_use_agent
          ''
        else
          (%w(-o IdentitiesOnly=yes) <<  key_paths).join(' ')
        end
      end

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

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
vagrant-vaimo-unison-0.0.2 lib/vagrant-vaimo-unison/ssh_command.rb
vagrant-vaimo-unison-0.0.1 lib/vagrant-vaimo-unison/ssh_command.rb
vagrant-unison-vaimo-4.0.0a lib/vagrant-unison-vaimo/ssh_command.rb
vagrant-unison-vaimo-1.0.0a lib/vagrant-unison-vaimo/ssh_command.rb
vagrant-unison2-2.0.0 lib/vagrant-unison2/ssh_command.rb