ec2ssh 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # Change Log
2
+ ## 2.0.1
3
+
4
+ * Fix bugs around initializing dotfile.
5
+
2
6
  ## 2.0.0
3
7
 
4
8
  * Add dotfile (.ec2ssh); supports multiple aws keys with `$ ec2ssh update --aws-key keyname` option.
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/mirakui/ec2ssh.png?branch=master)](https://travis-ci.org/mirakui/ec2ssh)
2
+
1
3
  # Introduction
2
4
  ec2ssh is a ssh_config manager for amazonaws ec2.
3
5
  `ec2ssh` command adds `Host` descriptions to ssh_config (~/.ssh/config default). 'Name' tag of instances are used as `Host` descriptions.
@@ -51,12 +53,29 @@ $ ec2ssh update # Update ec2 hosts list in ssh_config
51
53
  $ ec2ssh remove # Remove ec2ssh mark from ssh_config
52
54
  ```
53
55
 
54
- Each command can use `--path` option to set ssh_config path. The default is "~/.ssh/config"
56
+ ## Options
57
+ ### --path
58
+ Each command can use `--path` option to set ssh_config path. `~/.ssh/config` is default.
59
+
60
+ ```
61
+ $ ec2ssh init --path /path/to/ssh_config
62
+ ```
63
+
64
+ ### --dotfile
65
+ Each command can use `--dotfile` option to set dotfile (.ec2ssh) path. `~/.ec2ssh` is default.
55
66
 
56
67
  ```
57
- $ ec2ssh init --path=/path/to/ssh_config
68
+ $ ec2ssh init --dotfile /path/to/ssh_config
58
69
  ```
59
70
 
71
+ ### --aws-key
72
+ `ec2ssh update` allows `--aws-key` option. If you have multiple aws keys, you can choose from them as you like using this option. See Dotfile section for details.
73
+
74
+ ```
75
+ $ ec2ssh update --aws-key my_key1
76
+ ```
77
+
78
+
60
79
  # ssh_config and mark lines
61
80
  `ec2ssh init` command inserts mark lines your `.ssh/config` such as:
62
81
 
@@ -86,6 +105,61 @@ Host db-server-1.ap-southeast-1
86
105
 
87
106
  `ec2ssh remove` command removes the mark lines.
88
107
 
108
+ # Dotfile (.ec2ssh)
109
+ Dotfile (`.ec2ssh`) is a feature which is released at v2.0.0. A template of `.ec2ssh` is created when you execute `ec2ssh init`.
110
+
111
+ ```
112
+ $ ec2ssh init
113
+ $ cat ~/.ec2ssh
114
+ ---
115
+ path: /home/yourname/.ssh/config
116
+ aws_keys:
117
+ default:
118
+ access_key_id: ...(Filled by ENV['AMAZON_ACCESS_KEY_ID']
119
+ secret_access_key: ...(Filled by ENV['AMAZON_SECRET_ACCESS_KEY'])
120
+ regions:
121
+ - ap-northeast-1
122
+ ```
123
+
124
+ ## multiple aws keys
125
+ You can use multiple aws keys at `ec2ssh update` with `--aws-key` option.
126
+
127
+ ```
128
+ $ cat ~/.ec2ssh
129
+ ---
130
+ path: /home/yourname/.ssh/config
131
+ aws_keys:
132
+ default:
133
+ access_key_id: ...
134
+ secret_access_key: ...
135
+ my_key1:
136
+ access_key_id: ...
137
+ secret_access_key: ...
138
+ regions:
139
+ - ap-northeast-1
140
+ ```
141
+
142
+ Updating ssh_config by 'default' aws key:
143
+
144
+ ```
145
+ $ ec2ssh update
146
+ ```
147
+
148
+ Updates ssh_config by 'my_key1' aws key:
149
+
150
+ ```
151
+ $ ec2ssh update --aws-key my_key1
152
+ ```
153
+
154
+ # How to upgrade from 1.x to 2.x
155
+ If you have used ec2ssh-1.x, it seems that you may not have '~/.ec2ssh'.
156
+ So you need execute `ec2ssh init` once to create `~/.ec2ssh`, and edit it as you like.
157
+
158
+ ```
159
+ $ ec2ssh init
160
+ $ vi ~/.ec2ssh
161
+ ```
162
+
89
163
  # Notice
90
164
  `ec2ssh` command updates your `.ssh/config` file default. You should make a backup of it.
91
165
 
data/lib/ec2ssh/cli.rb CHANGED
@@ -18,7 +18,7 @@ module Ec2ssh
18
18
  config.append_mark!
19
19
  green "Added mark to #{config_path}"
20
20
  end
21
- dotfile = Dotfile.update_or_create(options.dotfile, 'path' => options.path)
21
+ dotfile = Dotfile.update_or_create(options.dotfile, 'path' => config_path)
22
22
  yellow "Please check and edit #{options.dotfile} before run `ec2ssh update`"
23
23
  end
24
24
 
@@ -63,11 +63,17 @@ Host #{h[:host]}
63
63
  end
64
64
 
65
65
  def dotfile
66
- @dotfile ||= Dotfile.load(options.dotfile)
66
+ @dotfile ||= begin
67
+ if File.exist?(options.dotfile)
68
+ Dotfile.load(options.dotfile)
69
+ else
70
+ Dotfile.new
71
+ end
72
+ end
67
73
  end
68
74
 
69
75
  def config_path
70
- options.path || dotfile['path'] || "#{$ENV['HOME']}/.ssh/config"
76
+ options.path || dotfile['path'] || "#{ENV['HOME']}/.ssh/config"
71
77
  end
72
78
 
73
79
  [:red,:green,:yellow].each do |col|
@@ -5,7 +5,7 @@ module Ec2ssh
5
5
  class Dotfile
6
6
  def initialize(config={})
7
7
  @config = {
8
- 'path' => "~/.ssh/config",
8
+ 'path' => "#{ENV['HOME']}/.ssh/config",
9
9
  'aws_keys' => {
10
10
  'default' => {
11
11
  'access_key_id' => ENV['AMAZON_ACCESS_KEY_ID'],
@@ -1,3 +1,4 @@
1
+ require 'time'
1
2
  require 'pathname'
2
3
 
3
4
  module Ec2ssh
@@ -1,3 +1,3 @@
1
1
  module Ec2ssh
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -15,6 +15,9 @@ describe Ec2ssh::CLI do
15
15
  end
16
16
  end
17
17
  end
18
+ before do
19
+ File.delete(dotfile_path) if File.exist?(dotfile_path)
20
+ end
18
21
  let(:cli) { described_class }
19
22
  let(:ssh_config_path) do
20
23
  path = tmp_dir.join('ssh_config')
@@ -33,7 +36,7 @@ Host foo.bar.com
33
36
  tz = ENV['TZ']
34
37
  ENV['TZ'] = 'UTC'
35
38
  Timecop.freeze(Time.local(2013,1,1,0,0,0)) { example.call }
36
- ENV['TZ'] = 'tz'
39
+ ENV['TZ'] = tz
37
40
  end
38
41
 
39
42
  subject { ssh_config_string }
metadata CHANGED
@@ -1,78 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ec2ssh
3
- version: !ruby/object:Gem::Version
4
- hash: 15
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.1
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 0
9
- - 0
10
- version: 2.0.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Issei Naruta
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-03-11 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: thor
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 43
29
- segments:
30
- - 0
31
- - 14
32
- - 6
20
+ - !ruby/object:Gem::Version
33
21
  version: 0.14.6
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: highline
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
40
25
  none: false
41
- requirements:
26
+ requirements:
42
27
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 1
47
- - 6
48
- version: "1.6"
28
+ - !ruby/object:Gem::Version
29
+ version: 0.14.6
30
+ - !ruby/object:Gem::Dependency
31
+ name: highline
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.6'
49
38
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: aws-sdk
53
39
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
55
41
  none: false
56
- requirements:
42
+ requirements:
57
43
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 31
60
- segments:
61
- - 1
62
- - 8
63
- version: "1.8"
44
+ - !ruby/object:Gem::Version
45
+ version: '1.6'
46
+ - !ruby/object:Gem::Dependency
47
+ name: aws-sdk
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.8'
64
54
  type: :runtime
65
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
66
62
  description: ec2ssh is a ssh_config manager for AWS EC2
67
- email:
63
+ email:
68
64
  - mimitako@gmail.com
69
- executables:
65
+ executables:
70
66
  - ec2ssh
71
67
  extensions: []
72
-
73
68
  extra_rdoc_files: []
74
-
75
- files:
69
+ files:
76
70
  - .gitignore
77
71
  - .rspec
78
72
  - .rvmrc
@@ -95,37 +89,28 @@ files:
95
89
  - spec/spec_helper.rb
96
90
  homepage: http://github.com/mirakui/ec2ssh
97
91
  licenses: []
98
-
99
92
  post_install_message:
100
93
  rdoc_options: []
101
-
102
- require_paths:
94
+ require_paths:
103
95
  - lib
104
- required_ruby_version: !ruby/object:Gem::Requirement
96
+ required_ruby_version: !ruby/object:Gem::Requirement
105
97
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- hash: 3
110
- segments:
111
- - 0
112
- version: "0"
113
- required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
103
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
- version: "0"
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
122
108
  requirements: []
123
-
124
109
  rubyforge_project: ec2ssh
125
- rubygems_version: 1.8.15
110
+ rubygems_version: 1.8.23
126
111
  signing_key:
127
112
  specification_version: 3
128
113
  summary: A ssh_config manager for AWS EC2
129
- test_files:
114
+ test_files:
130
115
  - spec/lib/ec2ssh/cli_spec.rb
131
116
  - spec/spec_helper.rb