vagrant-multi-putty 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +80 -0
- data/lib/vagrant-multi-putty.rb +2 -0
- data/lib/vagrant-multi-putty/command.rb +73 -0
- data/lib/vagrant-multi-putty/config.rb +9 -0
- data/lib/vagrant-multi-putty/version.rb +3 -0
- data/lib/vagrant_init.rb +1 -0
- data/vagrant-multi-putty.gemspec +19 -0
- metadata +70 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Nicholas Downs
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# vagrant-multi-putty
|
2
|
+
|
3
|
+
* Source: https://github.com/nickryand/vagrant-multi-putty
|
4
|
+
|
5
|
+
This plugin allows you to use putty to ssh into VMs. It has been tested on
|
6
|
+
Windows and should also work on Linux. Multi-vm environments are supported.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
### Software
|
10
|
+
To install this plugin for the gem version of Vagrant:
|
11
|
+
```
|
12
|
+
$ gem install vagrant-multi-putty
|
13
|
+
```
|
14
|
+
|
15
|
+
To install under the non-gem installed version of Vagrant:
|
16
|
+
```
|
17
|
+
$ vagrant gem install vagrant-multi-putty
|
18
|
+
```
|
19
|
+
|
20
|
+
### Putty Binary
|
21
|
+
Download: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
|
22
|
+
|
23
|
+
Download the putty executable for your platform and place it's location on your
|
24
|
+
PATH variable. Seek your operating system manual for instructions on how to
|
25
|
+
modify your PATH variable.
|
26
|
+
|
27
|
+
### SSH Private Key conversion using PuTTYgen
|
28
|
+
Download: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
|
29
|
+
|
30
|
+
Putty uses a custom format for SSH keys. It does not support openssl keys
|
31
|
+
directly. Using PuTTYgen, you can convert the private key shipped with vagrant
|
32
|
+
or convert a private key of your own.
|
33
|
+
|
34
|
+
#### Steps for converting the shipped insecure private key
|
35
|
+
1. Open puttygen and click the Conversions -> Import Key menu option.
|
36
|
+
2. Select the insecure_private_key located at ~/.vagrant.d/insecure_private_key
|
37
|
+
3. Click the "Save private key" button and store the key right along side the
|
38
|
+
insecure key.
|
39
|
+
4. Answer yes when prompted to save without a password.
|
40
|
+
5. Save the key using the filename of "insecure_private_key.ppk".
|
41
|
+
|
42
|
+
Note: If you do not explicity set the config.putty.private_key_path variable,
|
43
|
+
you need to convert the insecure_private_key and store it with the a ".ppk"
|
44
|
+
extension. The vagrant-multi-putty plugin appends this extension automatically.
|
45
|
+
|
46
|
+
## Configuration
|
47
|
+
Most of the ssh configuration options used to control vagrant ssh also
|
48
|
+
control vagrant-multi-putty. The following Vagrantfile options are NOT used by
|
49
|
+
vagrant-multi-putty:
|
50
|
+
|
51
|
+
* config.ssh.max_tries
|
52
|
+
* config.ssh.timeout
|
53
|
+
* config.ssh.private_key_path
|
54
|
+
* config.ssh.shell
|
55
|
+
|
56
|
+
All other config.ssh options should work for vagrant-multi-putty just like they
|
57
|
+
do for vagrant ssh.
|
58
|
+
|
59
|
+
There are currently two additional configuration parameters available:
|
60
|
+
|
61
|
+
* config.putty.username: Overrides the username set with
|
62
|
+
config.ssh.username.
|
63
|
+
* config.putty.private_key_path: Used to explicity set the path to the
|
64
|
+
private key variable.
|
65
|
+
|
66
|
+
## Usage
|
67
|
+
Basic usage:
|
68
|
+
```
|
69
|
+
vagrant putty
|
70
|
+
```
|
71
|
+
|
72
|
+
Login into a single vm in a multiple vm environment:
|
73
|
+
```
|
74
|
+
vagrant putty <name of vm>
|
75
|
+
```
|
76
|
+
|
77
|
+
Pass putty options directly to the putty binary:
|
78
|
+
```
|
79
|
+
vagrant putty -- -l testuser -i <path to private key>
|
80
|
+
```
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Pieces of this plugin were taken from the bundled vagrant ssh plugin.
|
2
|
+
require 'rubygems'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
module VagrantMuliPutty
|
6
|
+
class Command < Vagrant::Command::Base
|
7
|
+
def execute
|
8
|
+
options = {}
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant putty [vm-name...] [-- extra putty args]"
|
11
|
+
|
12
|
+
opts.on("-p", "--plain", "Plain auth mode which will require the user to provide a password.") do |p|
|
13
|
+
options[:plain_auth] = p
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.separator ""
|
17
|
+
end
|
18
|
+
|
19
|
+
argv = parse_options(opts)
|
20
|
+
return if !argv
|
21
|
+
|
22
|
+
# This is borrowed from the ssh base command that ships with vagrant.
|
23
|
+
# It is used to parse out arguments meant for the putty program.
|
24
|
+
putty_args = ARGV.drop_while { |i| i != "--" }
|
25
|
+
putty_args = putty_args[1..-1] if !putty_args.empty?
|
26
|
+
@logger.debug("Putty args: #{putty_args}")
|
27
|
+
|
28
|
+
# argv needs to be purged of the extra putty arguments. The remaining arguments
|
29
|
+
# (if any) will be the VM names to log into.
|
30
|
+
argv = argv - putty_args
|
31
|
+
|
32
|
+
# Since putty is a program with a GUI window, we can perform a spawn and
|
33
|
+
# detach the process from vagrant.
|
34
|
+
with_target_vms(argv) do |vm|
|
35
|
+
# Also borrowed from the base ssh.rb code.
|
36
|
+
# Basic checks needed for a putty connection
|
37
|
+
raise Vagrant::Errors::VMNotCreatedError if !vm.created?
|
38
|
+
raise Vagrant::Errors::VMInaccessible if !vm.state == :inaccessible
|
39
|
+
raise Vagrant::Errors::VMNotRunningError if vm.state != :running
|
40
|
+
|
41
|
+
@logger.info("Launching putty session to: #{vm.name}")
|
42
|
+
putty_connect(vm, putty_args, plain_auth=options[:plain_auth])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def putty_connect(vm, args, plain_auth=False)
|
47
|
+
# Get the path to the private key for VM.
|
48
|
+
private_key = vm.config.putty.private_key_path || "#{vm.env.default_private_key_path}.ppk"
|
49
|
+
pk_path = File.expand_path("#{private_key}", vm.env.root_path)
|
50
|
+
@logger.debug("Putty Private Key: #{pk_path}")
|
51
|
+
|
52
|
+
# Load options set in the Vagrantfile
|
53
|
+
ssh_port = vm.config.ssh.port || vm.driver.ssh_port(vm.config.ssh.guest_port)
|
54
|
+
options = [vm.config.ssh.host]
|
55
|
+
options += ["-l", vm.config.putty.username || vm.config.ssh.username]
|
56
|
+
options += ["-P", ssh_port.to_s]
|
57
|
+
options += ["-i", pk_path] if !plain_auth
|
58
|
+
options += ["-X"] if vm.config.ssh.forward_x11
|
59
|
+
options += ["-A"] if vm.config.ssh.forward_agent
|
60
|
+
|
61
|
+
# Add in additional args from the command line.
|
62
|
+
options.concat(args) if !args.nil?
|
63
|
+
|
64
|
+
# Spawn putty and detach it so we can move on.
|
65
|
+
@logger.debug("Putty cmd line options: #{options.to_s}")
|
66
|
+
pid = spawn("putty", *options)
|
67
|
+
@logger.debug("Putty Child Pid: #{pid}")
|
68
|
+
Process.detach(pid)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
Vagrant.commands.register(:putty) { Command }
|
73
|
+
end
|
data/lib/vagrant_init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'vagrant-multi-putty'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path("../lib/vagrant-multi-putty/version", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "vagrant-multi-putty"
|
5
|
+
s.version = VagrantMultiPutty::VERSION
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.authors = ["Nick Downs"]
|
8
|
+
s.email = ["nickryand@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/nickryand/vagrant-multi-putty"
|
10
|
+
s.summary = "Vagrant plugin to allow VM ssh with PuTTY (multi-vm supported)"
|
11
|
+
s.description = "Vagrant plugin to allow VM ssh with PuTTY (multi-vm supported)"
|
12
|
+
|
13
|
+
s.required_rubygems_version = ">= 1.4.0"
|
14
|
+
|
15
|
+
s.add_dependency "vagrant", "~> 1.0.5"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.require_path = 'lib'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-multi-putty
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nick Downs
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: vagrant
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.5
|
30
|
+
description: Vagrant plugin to allow VM ssh with PuTTY (multi-vm supported)
|
31
|
+
email:
|
32
|
+
- nickryand@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
40
|
+
- lib/vagrant-multi-putty.rb
|
41
|
+
- lib/vagrant-multi-putty/command.rb
|
42
|
+
- lib/vagrant-multi-putty/config.rb
|
43
|
+
- lib/vagrant-multi-putty/version.rb
|
44
|
+
- lib/vagrant_init.rb
|
45
|
+
- vagrant-multi-putty.gemspec
|
46
|
+
homepage: https://github.com/nickryand/vagrant-multi-putty
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.4.0
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.24
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Vagrant plugin to allow VM ssh with PuTTY (multi-vm supported)
|
70
|
+
test_files: []
|