bastion-cli 0.6.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.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +18 -0
- data/.travis.yml +18 -0
- data/Gemfile +3 -0
- data/Rakefile +11 -0
- data/bastion-cli.gemspec +24 -0
- data/bin/bastion +59 -0
- data/lib/bastion.rb +5 -0
- data/lib/bastion/config.rb +30 -0
- data/license.txt +22 -0
- data/readme.md +50 -0
- metadata +98 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: ef6a160a28190efc08e733c625ddfffec4dcac21
|
|
4
|
+
data.tar.gz: 327a6b108b622e2bf95075ff099d0a1118e1112d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4ee06e37f9f3b1fed8bf6a4553be3d7f2c4d1a1dba4676c811687f359f3dbeb240bec42b8a92806889ae3af8d2d4bb3158653f92951cc70c422c8eb4d44d07e6
|
|
7
|
+
data.tar.gz: 2d9792397b963c9abaab58d515819e5e16b0f6fe7ca516d681105cb31f01f7db131a18c23cbc00828293e8ac7af332b1fcd1a43a32fc69104b80f4e150a59a26
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metrics/LineLength:
|
|
2
|
+
Max: 80
|
|
3
|
+
|
|
4
|
+
Style/StringLiterals:
|
|
5
|
+
Enabled: false
|
|
6
|
+
|
|
7
|
+
Style/ClassVars:
|
|
8
|
+
Enabled: false
|
|
9
|
+
|
|
10
|
+
Style/MutableConstant:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
13
|
+
Style/TrailingCommaInLiteral:
|
|
14
|
+
Enabled: false
|
|
15
|
+
|
|
16
|
+
AllCops:
|
|
17
|
+
Include:
|
|
18
|
+
- Rakefile
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
language: ruby
|
|
2
|
+
rvm:
|
|
3
|
+
- 1.9.3-p551
|
|
4
|
+
- 2.3.0
|
|
5
|
+
deploy:
|
|
6
|
+
provider: rubygems
|
|
7
|
+
api_key:
|
|
8
|
+
secure: a0KqUg2kBe4aVmisadDybBXbAuolX5tKtbX6YGacbjwAeOb+aoemejgRHJKg8zGOlL8FvHwSY5kER+uapQpRXKW/pZnWTYL+GjCP66iF6qfq4Pueo09J3rIT/pnWz36nfZkd2AXSdKX/UtQQxZTzRdCiglVk0jeEiIFzhxXFS2FCBUt5h2ltciU4WKS5esHvtm+EixjLLFFbatdbeVs+mhbjp2ejmOjwTAZWbjM6bScFxksRrdeQhztK7eUbM+i2DzOC26iV9ejNBjqmFtNE6GPZJ0c24KtGnmy6VwxfGS89yibNnmkGHotPYFzn2mceH75h8U00Rn1d7EdGnGlE10UqVH9lTOLqAbhhxNmBscD+19Q2SnkWZ0u0khYX0fo6BBA0Q/TPAZfg/hBjGm42DVXz1ZS5PFmEa8eEmVZ/vXG2sQGchPEwj3IQlfY/pSSlgmFReHP2VzQO8hUCC4+NquZTQ6hgltIxZiWGbBcJgnU/GeSRd78drIWpAVl8BE1dnzWkcMyT5rgekDhWX8fyiJVYYKXO446vaE0rNyjXOOP4xCRfQ/5LRtoyEQcAPpH3rcXN+iUNKEvzl/YnBLiInEDlE5R7kTxqvE82YH0i2RhGfo568fQ4YKbRjVepahb47mxR1anL56e/9aV8jz44nWcCwvg2UH0NqdXanRzd4vk=
|
|
9
|
+
gem: bastion-cli
|
|
10
|
+
on:
|
|
11
|
+
tags: true
|
|
12
|
+
repo: ptdorf/bastion-cli
|
|
13
|
+
notifications:
|
|
14
|
+
email:
|
|
15
|
+
- ptdorf@gmail.com
|
|
16
|
+
slack:
|
|
17
|
+
rooms:
|
|
18
|
+
- secure: Jo5dE0CbXONghzx6RZQ3WeqSanHyIOw89A0gXoLTrvPh9/acBxsGm9XvGCQ6dkZlCm6t1U0FnPmXlrAF1Fx+jQ54dZv8f6fpL0V40iKFBGf4WcGHUgtV8pK505Eg1Ez4v30R14eodBF3yOHFeITbP/XtKdPss9YixQ8Bi02PUGwJ4Ako2GnWk8bsw2LLhVBbYt41ORSNEyMTJOdZgiyZcjJf8jDjHTo6R6+p/hO2CD5PkGE5iIVNiuASXIl2JAh+7j97hrfXVFSjbA5QnL7k0eGT9hSumak8atSZEtzuqVIH53SNk94tKEoFlJ83fPUyr2WSIrI1pkzCOTq30EgtHciG8iTuq6TkkOBmvdg3hZ/hVpX3DbLIEX/bgaE4lbrFfJCDZKEdUGxzbhHDU4kzkufHTMgJuPj84ZKyeouLaCRQJUFqW1sPWam6KWIctM0aDmrh543O8n2egfPTnDC9uxoX036kB0i56q1rj5sDnjVCZePwUXMdxp35SSYEfVHHjScyIV4uvVpSSWoXmVq7n/KBKmfyShZ+mj731eHcmzvxLJZh0GcTS1vWiXlCGRmPIJY7qrGD1gXAtUKDNJJlPDrLgTkFAbRjRKQ87BH2Tvr4LISrnYTi/yablFmTTBXL3wpRHf6hJvswOnXlQNXuqD60pT2aLgFvTnRTbJDIq5o=
|
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bastion-cli.gemspec
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
2
|
+
|
|
3
|
+
require "date"
|
|
4
|
+
require "bastion"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "bastion-cli"
|
|
8
|
+
spec.version = Bastion::VERSION
|
|
9
|
+
spec.date = (Date.today << 1).to_s
|
|
10
|
+
spec.description = "Log into bastion hosts"
|
|
11
|
+
spec.summary = "Log into bastion hosts (summary)"
|
|
12
|
+
spec.authors = ["ptdorf"]
|
|
13
|
+
spec.email = ["ptdorf@gmail.com"]
|
|
14
|
+
spec.homepage = "https://github.com/ptdorf/bastion-cli"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
spec.require_paths = ["lib"]
|
|
17
|
+
|
|
18
|
+
spec.files = `git ls-files`.split $/
|
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename f }
|
|
20
|
+
|
|
21
|
+
spec.add_dependency "thor"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
spec.add_development_dependency "rubocop"
|
|
24
|
+
end
|
data/bin/bastion
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + "/../lib")
|
|
4
|
+
|
|
5
|
+
require "rubygems"
|
|
6
|
+
require "thor"
|
|
7
|
+
require "bastion"
|
|
8
|
+
|
|
9
|
+
module Bastion
|
|
10
|
+
# Cli class
|
|
11
|
+
#
|
|
12
|
+
#
|
|
13
|
+
class Cli < Thor
|
|
14
|
+
Config.load
|
|
15
|
+
|
|
16
|
+
desc "ssh [INSTANCE]", "Logs into an instance"
|
|
17
|
+
option :host
|
|
18
|
+
option :save, type: :boolean
|
|
19
|
+
def ssh(instance = nil)
|
|
20
|
+
host = options[:host] || Config.host
|
|
21
|
+
Config.save host if options[:save]
|
|
22
|
+
if instance
|
|
23
|
+
puts "==> Using #{host}"
|
|
24
|
+
puts "==> Logging into #{instance}"
|
|
25
|
+
exec "ssh -A -t #{host} ssh #{instance}"
|
|
26
|
+
else
|
|
27
|
+
puts "==> Logging into #{host}"
|
|
28
|
+
exec "ssh -A #{host}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
desc "host [HOST]", "Show or set the default bastion host"
|
|
33
|
+
def host(address = nil)
|
|
34
|
+
return Config.save(address) if address
|
|
35
|
+
|
|
36
|
+
puts "DEFAULT #{Config.default}"
|
|
37
|
+
puts "SAVED #{Config.file}"
|
|
38
|
+
puts "ENV #{Config.env}"
|
|
39
|
+
puts "ACTUAL #{Config.host}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc "tunnel [PORT]", "Starts a new tunnel"
|
|
43
|
+
option :host
|
|
44
|
+
option :save, type: :boolean
|
|
45
|
+
def tunnel(port = 1200)
|
|
46
|
+
host = options[:host] || Config.host
|
|
47
|
+
SshConfig.save host if options[:save]
|
|
48
|
+
puts "==> Starting tunnel to host #{host} on port #{port}"
|
|
49
|
+
exec "ssh -D#{port} #{host}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
desc "version", "Shows current version"
|
|
53
|
+
def version
|
|
54
|
+
puts "v#{VERSION}"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Bastion::Cli.start ARGV
|
data/lib/bastion.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Bastion
|
|
2
|
+
# Config class
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
class Config
|
|
6
|
+
FILE = "#{ENV['HOME']}/.bastion"
|
|
7
|
+
NAME = "BASTION_HOST"
|
|
8
|
+
DEFAULT = "bastion.example.com"
|
|
9
|
+
|
|
10
|
+
def self.load
|
|
11
|
+
@@default = DEFAULT
|
|
12
|
+
@@env = ENV[NAME]
|
|
13
|
+
begin
|
|
14
|
+
@@file = File.open(FILE, "r").read
|
|
15
|
+
rescue
|
|
16
|
+
@@file = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
@@host = @@env || @@file || @@default
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.save(value)
|
|
23
|
+
File.write(FILE, value)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.method_missing(name)
|
|
27
|
+
class_variable_get(:"@@#{name}")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/license.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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.
|
data/readme.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# bastion-cli
|
|
2
|
+
|
|
3
|
+
Log into bastion hosts.
|
|
4
|
+
|
|
5
|
+
[](https://travis-ci.org/ptdorf/bastion-cli)
|
|
6
|
+
[](https://badge.fury.io/rb/bastion-cli)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```shell
|
|
11
|
+
sudo gem install bastion-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
# To see all options
|
|
18
|
+
bastion
|
|
19
|
+
|
|
20
|
+
# To log into an instance
|
|
21
|
+
bastion ssh 10.1.2.3
|
|
22
|
+
|
|
23
|
+
# To log into an instance specifying a bastion host
|
|
24
|
+
bastion ssh 10.1.2.3 --host 52.12.34.56
|
|
25
|
+
|
|
26
|
+
# To log into an instance specifying a bastion host and make it default
|
|
27
|
+
bastion ssh 10.1.2.3 --host 52.12.34.56 --save
|
|
28
|
+
|
|
29
|
+
# To show the default bastion host
|
|
30
|
+
bastion host
|
|
31
|
+
|
|
32
|
+
# To set the default bastion host
|
|
33
|
+
bastion host bastion.example.com
|
|
34
|
+
|
|
35
|
+
# To open a tunnel using the default bastion host
|
|
36
|
+
bastion tunnel
|
|
37
|
+
|
|
38
|
+
# To open a tunnel using the default bastion host on port 1337
|
|
39
|
+
bastion tunnel 1337
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
You can also set the `BASTION_HOST` environment variable with the address of the
|
|
43
|
+
bastion host:
|
|
44
|
+
|
|
45
|
+
BASTION_HOST=bastion.example.com bastion ssh web-01.example.com
|
|
46
|
+
|
|
47
|
+
The pecking order is:
|
|
48
|
+
|
|
49
|
+
- BASTION_HOST environment variable
|
|
50
|
+
- Default value on `${HOME}/.bastion`
|
metadata
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bastion-cli
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.6.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ptdorf
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rubocop
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
description: Log into bastion hosts
|
|
56
|
+
email:
|
|
57
|
+
- ptdorf@gmail.com
|
|
58
|
+
executables:
|
|
59
|
+
- bastion
|
|
60
|
+
extensions: []
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- .gitignore
|
|
64
|
+
- .rubocop.yml
|
|
65
|
+
- .travis.yml
|
|
66
|
+
- Gemfile
|
|
67
|
+
- Rakefile
|
|
68
|
+
- bastion-cli.gemspec
|
|
69
|
+
- bin/bastion
|
|
70
|
+
- lib/bastion.rb
|
|
71
|
+
- lib/bastion/config.rb
|
|
72
|
+
- license.txt
|
|
73
|
+
- readme.md
|
|
74
|
+
homepage: https://github.com/ptdorf/bastion-cli
|
|
75
|
+
licenses:
|
|
76
|
+
- MIT
|
|
77
|
+
metadata: {}
|
|
78
|
+
post_install_message:
|
|
79
|
+
rdoc_options: []
|
|
80
|
+
require_paths:
|
|
81
|
+
- lib
|
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
|
+
requirements:
|
|
84
|
+
- - '>='
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: '0'
|
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - '>='
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
requirements: []
|
|
93
|
+
rubyforge_project:
|
|
94
|
+
rubygems_version: 2.0.14
|
|
95
|
+
signing_key:
|
|
96
|
+
specification_version: 4
|
|
97
|
+
summary: Log into bastion hosts (summary)
|
|
98
|
+
test_files: []
|