From d86ae8cc33d1d61bd42d64810fb93efa27551218 Mon Sep 17 00:00:00 2001 From: MaxPeal <30347730+MaxPeal@users.noreply.github.com> Date: Sat, 4 May 2019 00:07:41 +0200 Subject: [PATCH 1/2] Update version.rb need to bump version, as via rubygems and also in vagrant we get only the files with version 1.6.0 but without last the commits / without the ssh_options --- lib/vagrant-multi-putty/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-multi-putty/version.rb b/lib/vagrant-multi-putty/version.rb index fa940bc..48435e8 100644 --- a/lib/vagrant-multi-putty/version.rb +++ b/lib/vagrant-multi-putty/version.rb @@ -1,3 +1,3 @@ module VagrantMultiPutty - VERSION = "1.6.0" + VERSION = "1.6.0.1" end From b8a7b549989bc258b99303110f270cc4c3dee898 Mon Sep 17 00:00:00 2001 From: MaxPeal <30347730+MaxPeal@users.noreply.github.com> Date: Sat, 4 May 2019 01:03:42 +0200 Subject: [PATCH 2/2] merge PRs, with WinSCP instead of putty (--scp option), and ssh options --- CHANGELOG.md | 12 ++++++++++++ README.md | 9 ++++++++- lib/vagrant-multi-putty/command.rb | 25 ++++++++++++++++++++----- lib/vagrant-multi-putty/config.rb | 3 +++ lib/vagrant-multi-putty/version.rb | 2 +- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4a731..df7db45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +v1.6.1.1 (2018-05-04) +------------------- + +FEATURES: + * Added the option to run WinSCP instead of putty. [GH-31] + +v1.6.0.1 +------------------- + +Bummp version for Merge pull request nickryand#30 from HenryNe/ssh_protocol_optional [GH-34] +config.putty.ssh_options: Allow end users define the Connection type or any other arguments. Default is `-ssh`. + v1.6.0 (2016-11-03) ------------------- diff --git a/README.md b/README.md index 2d3fa83..f850994 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,10 @@ There are currently a few additional configuration parameters available: * `config.putty.session`: Load settings from a saved putty session. * `config.putty.ssh_client`: Allow end users to control the path to the putty or putty like (kitty for example) binary. +* `config.putty.scp_client`: Allow end users to control the path to the WinSCP binary. Use slashes (not backslashes) for full path under Windows, for example: - `config.putty.ssh_client = "C:/Program Files (x86)/PuTTY/putty.exe"` + `config.putty.ssh_client = "C:/Program Files (x86)/PuTTY/putty.exe"` and + `config.putty.scp_client = "C:/Program Files (x86)/WinSCP/WinSCP.exe"` * `config.putty.ssh_options`: Allow end users define the Connection type or any other arguments. Multiple options separaed by comma. Default is `-ssh`. @@ -116,3 +118,8 @@ Pass putty options directly to the putty binary: ``` vagrant putty -- -l testuser -i ``` + +Run WinSCP instead of putty: +``` +vagrant putty --scp +``` diff --git a/lib/vagrant-multi-putty/command.rb b/lib/vagrant-multi-putty/command.rb index 7503320..0088eec 100644 --- a/lib/vagrant-multi-putty/command.rb +++ b/lib/vagrant-multi-putty/command.rb @@ -18,7 +18,8 @@ def execute end options = {:modal => @config.putty.modal, - :plain_auth => false } + :plain_auth => false, + :scp => false } opts = OptionParser.new do |opts| opts.banner = "Usage: vagrant putty [vm-name...] [-- extra putty args]" @@ -30,6 +31,10 @@ def execute options[:modal] = m end + opts.on("-s", "--scp", "Run WinSCP instead of putty") do |s| + options[:scp] = s + end + opts.separator "" end @@ -70,6 +75,7 @@ def putty_connect(vm, args, options={}) raise Vagrant::Errors::SSHNotReady if ssh_info.nil? ssh_options = [] + scp_options = [] # Load a saved putty session if provided. Putty (v0.63 at least) appears # to have a weird bug where a hostname specified on the command line will @@ -79,6 +85,8 @@ def putty_connect(vm, args, options={}) ssh_options += ["-load", vm.config.putty.session] if vm.config.putty.session + scp_options += ["scp://" + (vm.config.putty.username || ssh_info[:username]).to_s + "@" + ssh_info[:host] + ":" + ssh_info[:port].to_s] + # Load options from machine ssh_info. ssh_options += [ssh_info[:host]] # config.putty.username overrides the machines ssh_info username. @@ -105,14 +113,21 @@ def putty_connect(vm, args, options={}) ssh_options += [vm.config.putty.ssh_options] end end + scp_options += ["/privatekey=" + private_key] # Add in additional args from the command line. ssh_options.concat(args) if !args.nil? - # Spawn putty and detach it so we can move on. - @logger.debug("Putty cmd line options: #{ssh_options.to_s}") - pid = spawn(@config.putty.ssh_client, *ssh_options) - @logger.debug("Putty Child Pid: #{pid}") + # Spawn putty/SCP and detach it so we can move on. + if options[:scp] + @logger.debug("SCP cmd line options: #{scp_options.to_s}") + pid = spawn(@config.putty.scp_client, *scp_options) + @logger.debug("SCP child pid: #{pid}") + else + @logger.debug("Putty cmd line options: #{ssh_options.to_s}") + pid = spawn(@config.putty.ssh_client, *ssh_options) + @logger.debug("Putty Child Pid: #{pid}") + end Process.detach(pid) end diff --git a/lib/vagrant-multi-putty/config.rb b/lib/vagrant-multi-putty/config.rb index 3988f7c..3887f91 100644 --- a/lib/vagrant-multi-putty/config.rb +++ b/lib/vagrant-multi-putty/config.rb @@ -7,6 +7,7 @@ class PuttyConfig < Vagrant.plugin(2, :config) attr_accessor :session attr_accessor :ssh_client attr_accessor :ssh_options + attr_accessor :scp_client def after_modal &proc @after_modal_hook = proc @@ -20,6 +21,7 @@ def initialize @session = UNSET_VALUE @ssh_client = UNSET_VALUE @ssh_options = UNSET_VALUE + @scp_client = UNSET_VALUE end def finalize! @@ -30,6 +32,7 @@ def finalize! @session = nil if @session == UNSET_VALUE @ssh_client = "putty" if @ssh_client == UNSET_VALUE @ssh_options = "-ssh" if @ssh_options == UNSET_VALUE + @scp_client = "winscp.exe" if @scp_client == UNSET_VALUE end def validate(machine) diff --git a/lib/vagrant-multi-putty/version.rb b/lib/vagrant-multi-putty/version.rb index 48435e8..ba96a59 100644 --- a/lib/vagrant-multi-putty/version.rb +++ b/lib/vagrant-multi-putty/version.rb @@ -1,3 +1,3 @@ module VagrantMultiPutty - VERSION = "1.6.0.1" + VERSION = "1.6.1.1" end