Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version.rb #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
-------------------

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down Expand Up @@ -116,3 +118,8 @@ Pass putty options directly to the putty binary:
```
vagrant putty -- -l testuser -i <path to private key>
```

Run WinSCP instead of putty:
```
vagrant putty --scp
```
25 changes: 20 additions & 5 deletions lib/vagrant-multi-putty/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]"

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions lib/vagrant-multi-putty/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,6 +21,7 @@ def initialize
@session = UNSET_VALUE
@ssh_client = UNSET_VALUE
@ssh_options = UNSET_VALUE
@scp_client = UNSET_VALUE
end

def finalize!
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-multi-putty/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module VagrantMultiPutty
VERSION = "1.6.0"
VERSION = "1.6.1.1"
end