bastion-cli 0.7.8 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{readme.md → Readme.md} +6 -3
- data/bin/bastion +20 -23
- data/lib/bastion/config.rb +29 -16
- data/lib/bastion/version.rb +1 -1
- metadata +3 -4
- data/license.txt +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30e468497b9e751497941893f0078bf70d8a7088
|
4
|
+
data.tar.gz: 78cbf4d372567df0e755ddb0b817c524b1068a27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 317f92619bf0623345d0bf153a6edda2a21ce3ace5e26dd165d18c2499eb2a9beb98ee57370fd17d80c67a860abd879b6a9fc23792ca32eed26c79da04194e30
|
7
|
+
data.tar.gz: 013eae5e5fdbe28d5fa10c69002e27e4faefac0072c5b574258382f6cffef0882ff9baefdfb0ee72d2e14a852454fd1e747833d2a63b13442a548d913734f570
|
data/{readme.md → Readme.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
# bastion
|
1
|
+
# bastion
|
2
2
|
|
3
3
|
Log into things through bastions.
|
4
4
|
|
@@ -54,6 +54,9 @@ bastion host:
|
|
54
54
|
|
55
55
|
The pecking order is:
|
56
56
|
|
57
|
-
- `
|
58
|
-
- The
|
57
|
+
- The `--host` option
|
58
|
+
- The `BASTION_HOST` environment variable
|
59
|
+
- The user default value that lives in `/etc/bastion/bastion`
|
60
|
+
- The system default value that lives in `${HOME}/.bastion`
|
59
61
|
|
62
|
+
In doubt, just run `bastion host --all` to see what are your options.
|
data/bin/bastion
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + "/../lib")
|
2
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + "/../lib"
|
4
3
|
|
5
4
|
require "rubygems"
|
6
5
|
require "thor"
|
7
6
|
require "bastion"
|
8
7
|
|
9
8
|
module Bastion
|
10
|
-
|
11
|
-
|
9
|
+
# Main cli class
|
10
|
+
#
|
11
|
+
#
|
12
12
|
class Cli < Thor
|
13
|
-
|
13
|
+
class_option :host, type: :string
|
14
|
+
class_option :save, type: :boolean
|
15
|
+
class_option :v, type: :boolean
|
14
16
|
|
15
17
|
desc "version", "Shows current version"
|
16
18
|
def version
|
@@ -18,38 +20,33 @@ module Bastion
|
|
18
20
|
end
|
19
21
|
|
20
22
|
desc "host [HOST]", "Show or set the default bastion host"
|
23
|
+
option :all, type: :boolean
|
21
24
|
def host(address = nil)
|
22
|
-
|
23
|
-
|
25
|
+
config = Config.new(options)
|
26
|
+
return config.save(address) if address
|
27
|
+
return config.info if options[:all]
|
28
|
+
puts config.host
|
24
29
|
end
|
25
30
|
|
26
31
|
desc "ssh [INSTANCE]", "Logs into an instance"
|
27
|
-
option :host
|
28
|
-
option :save, type: :boolean
|
29
|
-
option :v, type: :boolean
|
30
32
|
def ssh(instance = nil)
|
31
|
-
|
33
|
+
config = Config.new(options)
|
32
34
|
verb = options[:v] ? " -vvv" : ""
|
33
|
-
Config.save host if options[:save]
|
34
35
|
if instance
|
35
|
-
puts "==> Using #{host}"
|
36
|
+
puts "==> Using #{config.host}"
|
36
37
|
puts "==> Logging into #{instance}"
|
37
|
-
exec "ssh -A -t #{host} ssh #{instance}#{verb}"
|
38
|
+
exec "ssh -A -t #{config.host} ssh #{instance}#{verb}"
|
38
39
|
else
|
39
|
-
puts "==> Logging into #{host}"
|
40
|
-
exec "ssh -A #{host}#{verb}"
|
40
|
+
puts "==> Logging into #{config.host}"
|
41
|
+
exec "ssh -A #{config.host}#{verb}"
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
45
|
desc "tunnel [PORT]", "Starts a new tunnel"
|
45
|
-
option :host
|
46
|
-
option :save, type: :boolean
|
47
|
-
option :v, type: :boolean
|
48
46
|
def tunnel(port = 1200)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
exec "ssh -D#{port} #{host}"
|
47
|
+
config = Config.new(options)
|
48
|
+
puts "==> Starting tunnel to host #{config.host} on port #{port}"
|
49
|
+
exec "ssh -D#{port} #{config.host}"
|
53
50
|
end
|
54
51
|
|
55
52
|
def method_missing(name)
|
data/lib/bastion/config.rb
CHANGED
@@ -3,28 +3,41 @@ module Bastion
|
|
3
3
|
#
|
4
4
|
#
|
5
5
|
class Config
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
USER = "#{ENV['HOME']}/.bastion"
|
7
|
+
SYSTEM = "/etc/bastion/bastion"
|
8
|
+
ENVVAR = "BASTION_HOST"
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
def initialize(options)
|
11
|
+
@system = read(SYSTEM)
|
12
|
+
@user = read(USER)
|
13
|
+
@env = ENV[ENVVAR]
|
14
|
+
@option = options[:host]
|
15
|
+
@host = @option || @env || @user || @system
|
16
|
+
save @host if options[:save]
|
17
|
+
end
|
18
|
+
|
19
|
+
def info
|
20
|
+
puts "System : #{@system}"
|
21
|
+
puts "User : #{@user}"
|
22
|
+
puts "Env : #{@env}"
|
23
|
+
puts "Option : #{@option}"
|
24
|
+
puts "Used : #{@host}"
|
25
|
+
end
|
18
26
|
|
19
|
-
|
27
|
+
def read(file, default = nil)
|
28
|
+
return default unless File.exist?(file)
|
29
|
+
value = File.read(file)
|
30
|
+
value.empty? ? nil : value
|
20
31
|
end
|
21
32
|
|
22
|
-
def
|
23
|
-
|
33
|
+
def save(value)
|
34
|
+
puts "Saved with value #{value}"
|
35
|
+
File.write USER, value
|
24
36
|
end
|
25
37
|
|
26
|
-
def
|
27
|
-
|
38
|
+
def method_missing(name)
|
39
|
+
instance_variable_get :"@#{name}"
|
40
|
+
# class_variable_get(:"@@#{name}")
|
28
41
|
end
|
29
42
|
end
|
30
43
|
end
|
data/lib/bastion/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bastion-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ptdorf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -65,13 +65,12 @@ files:
|
|
65
65
|
- .travis.yml
|
66
66
|
- Gemfile
|
67
67
|
- Rakefile
|
68
|
+
- Readme.md
|
68
69
|
- bastion-cli.gemspec
|
69
70
|
- bin/bastion
|
70
71
|
- lib/bastion.rb
|
71
72
|
- lib/bastion/config.rb
|
72
73
|
- lib/bastion/version.rb
|
73
|
-
- license.txt
|
74
|
-
- readme.md
|
75
74
|
homepage: https://github.com/ptdorf/bastion-cli
|
76
75
|
licenses:
|
77
76
|
- MIT
|
data/license.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2016 ptdorf
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|