ec2-ssh 1.0.6 → 1.0.7
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 +4 -4
- data/README.md +70 -23
- data/lib/ec2-ssh.rb +1 -1
- data/lib/ec2-ssh/cli.rb +2 -2
- data/lib/ec2-ssh/ssh.rb +9 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a43390b18f7b48ba844f69545f8d87df9b6ba24
|
|
4
|
+
data.tar.gz: 495ebb1852a3542bb8736f897b3da2ac3a9517ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d4127869a0221b255591ef2f95a1507f3b773faedea620ca3e923ed7e46173dea1cd0449d3b186e0498772e7de56f64b25b1f76af9ba968e5544e9f201a505f
|
|
7
|
+
data.tar.gz: 65e8f5e1507dca883d67746b4b1a43077ef29a08885910980138e74eddb40354074daf8779a6c1aa3620c17768d14f68e120cdd27e3a44cd016c85961643cb8b
|
data/README.md
CHANGED
|
@@ -1,41 +1,88 @@
|
|
|
1
|
-
This utility
|
|
1
|
+
This is a utility for connecting on ec2to autoscale groups and run multiple commands either parallel sequential or in groups
|
|
2
2
|
|
|
3
|
+
(based on sshkit https://github.com/capistrano/sshkit)
|
|
3
4
|
|
|
5
|
+
use it where you need to upload / download / capture output/ exec commands
|
|
6
|
+
|
|
7
|
+
````txt
|
|
4
8
|
seperate commands with a semicolon
|
|
5
9
|
|
|
6
10
|
default region: us-east-1
|
|
7
11
|
default user: ec2-user
|
|
8
12
|
default connnection :parallel
|
|
9
|
-
|
|
13
|
+
````
|
|
10
14
|
|
|
11
15
|
Groups were designed in this case to relieve problems (mass Git checkouts) where you rely on a contested resource that you don't want to DDOS by hitting it too hard.
|
|
12
16
|
|
|
13
17
|
Sequential runs were intended to be used for rolling restarts, amongst other similar use-cases.
|
|
14
18
|
|
|
19
|
+
if the instance is on a private subnet (given you have a VPN connection) it will fallback to connecting using the internal IP address
|
|
20
|
+
|
|
21
|
+
##examples:
|
|
22
|
+
|
|
23
|
+
--terminal (-t) will open multiple terminals windows of all servers found (currently only supported on OSX iTerm2)
|
|
24
|
+
````bash
|
|
25
|
+
$ ec2-ssh -t --tag-value ElasticSearch
|
|
26
|
+
````
|
|
27
|
+
-------------------
|
|
28
|
+
upload / download separate source,destination with a comma
|
|
29
|
+
````bash
|
|
30
|
+
$ ec2-ssh --download /home/ec2-user/file.txt,~/Downloads --tag-value ElasticSearch
|
|
31
|
+
````
|
|
32
|
+
-------------------
|
|
33
|
+
coonect to instances filter by custom tag
|
|
34
|
+
````bash
|
|
35
|
+
$ ec2-ssh --tag-key staging --tag-value true --cmd 'touch /tmp/test'
|
|
36
|
+
````
|
|
37
|
+
-------------------
|
|
38
|
+
pass profile of aws/credentials to use different accounts on AWS
|
|
39
|
+
(http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)
|
|
40
|
+
````bash
|
|
41
|
+
$ ec2-ssh --tag-value ElasticSearch --profile otherAccountName --cmd 'touch /tmp/test'
|
|
42
|
+
````
|
|
43
|
+
-------------------
|
|
15
44
|
|
|
16
|
-
|
|
45
|
+
connect by selecting autoscale group name
|
|
17
46
|
|
|
47
|
+
````bash
|
|
48
|
+
$ ec2-ssh --as --cmd 'touch /tmp/test'
|
|
18
49
|
|
|
50
|
+
0: ElasticSearch-ElasticSearchServerGroup1
|
|
51
|
+
1: KibanaServerGroup
|
|
52
|
+
3: LogstashServerGroup
|
|
53
|
+
4: ...
|
|
54
|
+
````
|
|
55
|
+
simply selct the number corresponding to the autoscale group (limit of AWS SDk is to fetch maximum 100 AutoScale Groups)
|
|
56
|
+
|
|
57
|
+
-------------------
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
##Possible command line options
|
|
61
|
+
````bash
|
|
19
62
|
Usage:
|
|
20
|
-
ec2-ssh connect
|
|
63
|
+
ec2-ssh connect
|
|
21
64
|
|
|
22
65
|
Options:
|
|
23
|
-
--cmd=CMD
|
|
24
|
-
[--profile=PROFILE]
|
|
25
|
-
|
|
26
|
-
[--region=REGION]
|
|
27
|
-
|
|
28
|
-
u, [--user=USER]
|
|
29
|
-
|
|
30
|
-
p, [--parallel=PARALLEL]
|
|
31
|
-
s, [--sequence=SEQUENCE]
|
|
32
|
-
g, [--groups=GROUPS]
|
|
33
|
-
l, [--groups-limit=N]
|
|
34
|
-
w, [--wait=N]
|
|
35
|
-
[--as=AS]
|
|
36
|
-
[--tag-key=TAG_KEY]
|
|
37
|
-
|
|
38
|
-
[--tag-value=TAG_VALUE]
|
|
39
|
-
t, [--terminal=TERMINAL]
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
[--cmd=CMD] # commmand to run on remote servers
|
|
67
|
+
[--profile=PROFILE] # Aws cli profile name as listed in ~/aws/credentials
|
|
68
|
+
# Default: default
|
|
69
|
+
[--region=REGION] # region
|
|
70
|
+
# Default: us-east-1
|
|
71
|
+
u, [--user=USER] # run as user
|
|
72
|
+
# Default: ec2-user
|
|
73
|
+
p, [--parallel=PARALLEL] # run in parallel
|
|
74
|
+
s, [--sequence=SEQUENCE] # run in sequence
|
|
75
|
+
g, [--groups=GROUPS] # run in groups
|
|
76
|
+
l, [--groups-limit=N] # limit
|
|
77
|
+
w, [--wait=N] # wait
|
|
78
|
+
[--as=AS] # filter by autoscale groups
|
|
79
|
+
[--tag-key=TAG_KEY] # tag key to filter instances by
|
|
80
|
+
# Default: Name
|
|
81
|
+
[--tag-value=TAG_VALUE] # tag value to filter instances by
|
|
82
|
+
t, [--terminal=TERMINAL] # open terminal tabs for all servers
|
|
83
|
+
c, [--capture-output=CAPTURE_OUTPUT] # capture output
|
|
84
|
+
[--upload=source,destination] # upload a file - source,destination (make sure seperate these by comma)
|
|
85
|
+
[--download=source,destination] # download a file - source,destination (make sure seperate these by comma)
|
|
86
|
+
|
|
87
|
+
Connect to autoscale instance (random instance), Pass --cmd='whatever' to run a cmd on the server (use ; to seperate commands)
|
|
88
|
+
````
|
data/lib/ec2-ssh.rb
CHANGED
data/lib/ec2-ssh/cli.rb
CHANGED
|
@@ -33,12 +33,12 @@ class Ec2Ssh::Cli < Thor
|
|
|
33
33
|
method_option :capture_output, :aliases => 'c', :desc => 'capture output'
|
|
34
34
|
method_option :upload, :desc => 'upload a file - source,destination (make sure seperate these by comma)', :banner => 'source,destination'
|
|
35
35
|
method_option :download, :desc => 'download a file - source,destination (make sure seperate these by comma)', :banner => 'source,destination'
|
|
36
|
-
|
|
36
|
+
method_option :pty, :desc => 'enable pty for sudo operations', :default => false
|
|
37
37
|
def connect
|
|
38
38
|
extend Aws
|
|
39
39
|
extend Ssh
|
|
40
40
|
extend Utils
|
|
41
|
-
set_ssh(options[:user])
|
|
41
|
+
set_ssh(options[:user], options[:pty])
|
|
42
42
|
aws_init(options[:profile], options[:region])
|
|
43
43
|
|
|
44
44
|
if options[:as]
|
data/lib/ec2-ssh/ssh.rb
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
module Ec2Ssh::Cli::Ssh
|
|
2
|
-
def set_ssh(user)
|
|
2
|
+
def set_ssh(user, pty)
|
|
3
3
|
ENV['SSHKIT_COLOR'] = 'TRUE'
|
|
4
4
|
SSHKit.config.output_verbosity = Logger::DEBUG
|
|
5
|
-
|
|
6
|
-
ssh.ssh_options = {
|
|
5
|
+
ssh_options = {
|
|
7
6
|
:user => user,
|
|
8
7
|
:paranoid => false,
|
|
9
8
|
:forward_agent => true,
|
|
10
9
|
:user_known_hosts_file => '/dev/null'
|
|
11
|
-
}
|
|
12
10
|
}
|
|
11
|
+
|
|
12
|
+
SSHKit::Backend::Netssh.configure { |ssh|
|
|
13
|
+
ssh.ssh_options = ssh_options
|
|
14
|
+
ssh.pty = true if pty
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
13
18
|
end
|
|
14
19
|
|
|
15
20
|
def ssh_to(user, dsl_options, cmd, capture_output, upload, download)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ec2-ssh
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ami Mahloof
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|