cap-ssh-key-man 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.2"
12
+ gem "rcov", ">= 0"
13
+ end
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "cap-ssh-key-man"
18
+ gem.homepage = "http://github.com/hlxwell/cap-ssh-key-man"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{This tool is used to mass deploy ssh-keys to all your servers according to the capistrano config.}
21
+ gem.description = %Q{This tool is used to mass deploy ssh-keys to all your servers according to the capistrano config.}
22
+ gem.email = "hlxwell@gmail.com"
23
+ gem.authors = ["Michael He"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{cap-ssh-key-man}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael He"]
12
+ s.date = %q{2011-12-15}
13
+ s.description = %q{This tool is used to mass deploy ssh-keys to all your servers according to the capistrano config.}
14
+ s.email = %q{hlxwell@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "README",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "cap-ssh-key-man.gemspec",
24
+ "lib/cap-ssh-key-man.rb",
25
+ "lib/cap-ssh-key-man/public_key_combiner.rb",
26
+ "lib/cap-ssh-key-man/tasks/sync.rb"
27
+ ]
28
+ s.homepage = %q{http://github.com/hlxwell/cap-ssh-key-man}
29
+ s.licenses = ["MIT"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = %q{1.6.2}
32
+ s.summary = %q{This tool is used to mass deploy ssh-keys to all your servers according to the capistrano config.}
33
+
34
+ if s.respond_to? :specification_version then
35
+ s.specification_version = 3
36
+
37
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
38
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
39
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
40
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
41
+ s.add_development_dependency(%q<rcov>, [">= 0"])
42
+ else
43
+ s.add_dependency(%q<shoulda>, [">= 0"])
44
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
45
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
46
+ s.add_dependency(%q<rcov>, [">= 0"])
47
+ end
48
+ else
49
+ s.add_dependency(%q<shoulda>, [">= 0"])
50
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
52
+ s.add_dependency(%q<rcov>, [">= 0"])
53
+ end
54
+ end
55
+
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'cap-ssh-key-man/tasks/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,26 @@
1
+ module CapSshKeyMan
2
+ class PublicKeyCombiner
3
+ def self.combine_developer_public_keys
4
+ authorized_keys_path = File.join ".", "tmp", "authorized_keys"
5
+ public_key_path = File.join(".", "config", "developer_public_keys")
6
+
7
+ File.open authorized_keys_path, "w" do |f|
8
+ f.write File.read(get_current_user_public_key_path) if get_current_user_public_key_path
9
+ files = Dir[File.join(public_key_path, '*')]
10
+ raise "Can't find any public keys in #{public_key_path} dir." if files.size == 0
11
+ files.each do |file|
12
+ f.write File.read(file)
13
+ end
14
+ end
15
+ end
16
+
17
+ def self.get_current_user_public_key_path
18
+ omni_rsa_key_path = File.expand_path(File.join "~", ".ssh", "id_rsa.pub")
19
+ omni_dsa_key_path = File.expand_path(File.join "~", ".ssh", "id_dsa.pub")
20
+ current_user_key_path = nil
21
+ current_user_key_path = omni_rsa_key_path if File.exist?(omni_rsa_key_path)
22
+ current_user_key_path = omni_dsa_key_path if File.exist?(omni_dsa_key_path)
23
+ current_user_key_path
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ require "cap-ssh-key-man/public_key_combiner"
2
+ Capistrano::Configuration.instance(true).load do
3
+ namespace :cap_ssh_key_man do
4
+ desc "Sync keys to servers"
5
+ task :sync do
6
+ puts "Creating authorized_keys file ..."
7
+ CapSshKeyMan::PublicKeyCombiner.combine_developer_public_keys
8
+
9
+ puts "Deploying authorized_keys ..."
10
+ tmp_authorized_keys_path = File.join(".", "tmp", "authorized_keys")
11
+ put File.read(tmp_authorized_keys_path), File.join("/home/#{user}", "authorized_keys")
12
+
13
+ # delete temp file after use it.
14
+ FileUtils.rm tmp_authorized_keys_path
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cap-ssh-key-man
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Michael He
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-12-15 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ name: shoulda
33
+ version_requirements: *id001
34
+ prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 23
43
+ segments:
44
+ - 1
45
+ - 0
46
+ - 0
47
+ version: 1.0.0
48
+ name: bundler
49
+ version_requirements: *id002
50
+ prerelease: false
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 11
59
+ segments:
60
+ - 1
61
+ - 6
62
+ - 2
63
+ version: 1.6.2
64
+ name: jeweler
65
+ version_requirements: *id003
66
+ prerelease: false
67
+ - !ruby/object:Gem::Dependency
68
+ type: :development
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ name: rcov
79
+ version_requirements: *id004
80
+ prerelease: false
81
+ description: This tool is used to mass deploy ssh-keys to all your servers according to the capistrano config.
82
+ email: hlxwell@gmail.com
83
+ executables: []
84
+
85
+ extensions: []
86
+
87
+ extra_rdoc_files:
88
+ - README
89
+ files:
90
+ - Gemfile
91
+ - README
92
+ - Rakefile
93
+ - VERSION
94
+ - cap-ssh-key-man.gemspec
95
+ - lib/cap-ssh-key-man.rb
96
+ - lib/cap-ssh-key-man/public_key_combiner.rb
97
+ - lib/cap-ssh-key-man/tasks/sync.rb
98
+ has_rdoc: true
99
+ homepage: http://github.com/hlxwell/cap-ssh-key-man
100
+ licenses:
101
+ - MIT
102
+ post_install_message:
103
+ rdoc_options: []
104
+
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ requirements: []
126
+
127
+ rubyforge_project:
128
+ rubygems_version: 1.6.2
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: This tool is used to mass deploy ssh-keys to all your servers according to the capistrano config.
132
+ test_files: []
133
+