assh 0.0.2
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +42 -0
- data/Rakefile +1 -0
- data/assh.gemspec +25 -0
- data/bin/assh +42 -0
- data/lib/assh.rb +22 -0
- data/lib/assh/version.rb +3 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# assh
|
2
|
+
|
3
|
+
An Amazon EC2 SSH assistant. You no longer have to remember hosts/ips:
|
4
|
+
|
5
|
+
$ gem install assh
|
6
|
+
|
7
|
+
Then export your EC2 key and secret:
|
8
|
+
|
9
|
+
$ export EC2_KEY=<your-key>
|
10
|
+
$ export EC2_SECRET=<your-key-secret>
|
11
|
+
|
12
|
+
Now go ahead and connect to a named instance:
|
13
|
+
|
14
|
+
$ assh connect nodejs
|
15
|
+
connecting to 192.168.2.1
|
16
|
+
...
|
17
|
+
...
|
18
|
+
|
19
|
+
You can also use wildcards:
|
20
|
+
|
21
|
+
$ assh connect "database*"
|
22
|
+
Pick an instance
|
23
|
+
1. database-test
|
24
|
+
2. database-qa2
|
25
|
+
3. database-dev
|
26
|
+
? 2
|
27
|
+
connecting to 192.168.2.2
|
28
|
+
...
|
29
|
+
...
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
## Copyright
|
40
|
+
|
41
|
+
Copyright (c) 2011 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot). See MIT-LICENSE for further details.
|
42
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/assh.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "assh/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "assh"
|
7
|
+
s.version = Assh::VERSION
|
8
|
+
s.authors = ["Dotan Nahum"]
|
9
|
+
s.email = ["jondotan@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{ssh productivity tools for Amazon EC2}
|
12
|
+
s.description = %q{ssh productivity tools for Amazon EC2}
|
13
|
+
|
14
|
+
s.rubyforge_project = "assh"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
s.add_runtime_dependency "aws-sdk"
|
24
|
+
s.add_runtime_dependency "commander"
|
25
|
+
end
|
data/bin/assh
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path('../lib', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'commander/import'
|
6
|
+
require 'assh'
|
7
|
+
|
8
|
+
program :version, Assh::VERSION
|
9
|
+
program :description, 'Amazon SSH'
|
10
|
+
|
11
|
+
default_command = :connect
|
12
|
+
|
13
|
+
global_option '--key KEY', String, 'EC2 access key'
|
14
|
+
global_option '--secret SECRET', String, 'EC2 access secret'
|
15
|
+
|
16
|
+
|
17
|
+
command :connect do |c|
|
18
|
+
c.syntax = 'aash connect [options]'
|
19
|
+
c.summary = 'SSH to a named EC2 instance'
|
20
|
+
|
21
|
+
c.option '--user USER', String, 'EC2 pem'
|
22
|
+
c.option '--pem PEM', String, 'EC2 pem'
|
23
|
+
|
24
|
+
c.action do |args, options|
|
25
|
+
options[:key] ||= ENV["EC2_KEY"]
|
26
|
+
options[:secret] ||= ENV["EC2_SECRET"]
|
27
|
+
|
28
|
+
|
29
|
+
assh = Assh::Core.new(options)
|
30
|
+
candidates = assh.list(args[0])
|
31
|
+
|
32
|
+
if(candidates.count == 1)
|
33
|
+
assh.connect(candidates.first)
|
34
|
+
else
|
35
|
+
imap= {}
|
36
|
+
candidates.each{|c| imap["#{c.tags.to_h['Name']}"] = c}
|
37
|
+
s = choose("Pick an instance", *imap.keys)
|
38
|
+
assh.connect imap[s]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
data/lib/assh.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "assh/version"
|
2
|
+
require 'aws-sdk'
|
3
|
+
|
4
|
+
module Assh
|
5
|
+
class Core
|
6
|
+
def initialize(opts)
|
7
|
+
@opts = opts
|
8
|
+
end
|
9
|
+
|
10
|
+
def connect(name)
|
11
|
+
ip = name.ip_address
|
12
|
+
puts "connecting to #{ip}"
|
13
|
+
exec "ssh#{@opts.pem ? ' -i ' + @opts.pem : '' } #{@opts.user}@#{ip}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def list(name)
|
17
|
+
c = AWS::EC2.new :access_key_id => @opts.key,
|
18
|
+
:secret_access_key => @opts.secret
|
19
|
+
c.instances.tagged('Name').tagged_values(name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/assh/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: assh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dotan Nahum
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: aws-sdk
|
16
|
+
requirement: &80695160 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *80695160
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: commander
|
27
|
+
requirement: &80694880 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *80694880
|
36
|
+
description: ssh productivity tools for Amazon EC2
|
37
|
+
email:
|
38
|
+
- jondotan@gmail.com
|
39
|
+
executables:
|
40
|
+
- assh
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- assh.gemspec
|
49
|
+
- bin/assh
|
50
|
+
- lib/assh.rb
|
51
|
+
- lib/assh/version.rb
|
52
|
+
homepage: ''
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project: assh
|
72
|
+
rubygems_version: 1.8.7
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: ssh productivity tools for Amazon EC2
|
76
|
+
test_files: []
|