cap-ssh-key-man 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/VERSION +1 -1
- data/cap-ssh-key-man.gemspec +1 -1
- data/lib/cap-ssh-key-man/public_key_combiner.rb +14 -9
- data/lib/cap-ssh-key-man/tasks/sync.rb +4 -6
- metadata +3 -3
data/README.md
CHANGED
@@ -12,9 +12,9 @@ Usage
|
|
12
12
|
|
13
13
|
2. Add `require 'cap-ssh-key-man/tasks/rsync'` to `config/deploy.rb` of your rails project.
|
14
14
|
|
15
|
-
3.
|
15
|
+
3. Add `set :sshkeys_path, PATH_TO_SSHKEYS_STORE_PATH` to `deploy.rb`.
|
16
16
|
|
17
|
-
4.
|
17
|
+
4. Put all public ssh keys to `PATH_TO_SSHKEYS_STORE_PATH` dir of your rails project.
|
18
18
|
|
19
19
|
5. Execute `cap sshkey:deploy`
|
20
20
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/cap-ssh-key-man.gemspec
CHANGED
@@ -1,19 +1,24 @@
|
|
1
1
|
module CapSshKeyMan
|
2
2
|
class PublicKeyCombiner
|
3
|
-
AUTHORIZED_KEYS_PATH = File.join ".", "tmp", "authorized_keys"
|
3
|
+
# AUTHORIZED_KEYS_PATH = File.join ".", "tmp", "authorized_keys"
|
4
4
|
PUBLIC_KEY_PATH = File.join(".", "config", "developer_public_keys")
|
5
5
|
OMNI_RSA_KEY_PATH = File.expand_path(File.join "~", ".ssh", "id_rsa.pub")
|
6
6
|
OMNI_DSA_KEY_PATH = File.expand_path(File.join "~", ".ssh", "id_dsa.pub")
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
def self.combine_developer_public_keys_in public_key_path
|
9
|
+
public_key_path ||= PUBLIC_KEY_PATH
|
10
|
+
abort "Please put your public keys in #{public_key_path}." unless File.exist?(public_key_path)
|
11
|
+
|
12
|
+
authorized_keys_string = ""
|
13
|
+
authorized_keys_string << File.read(get_current_user_public_key_path) if get_current_user_public_key_path
|
14
|
+
|
15
|
+
files = Dir[File.join(public_key_path, '*')]
|
16
|
+
raise "Can't find any public keys in #{public_key_path} dir." if files.size == 0
|
17
|
+
files.each do |file|
|
18
|
+
authorized_keys_string << File.read(file)
|
16
19
|
end
|
20
|
+
|
21
|
+
authorized_keys_string
|
17
22
|
end
|
18
23
|
|
19
24
|
def self.get_current_user_public_key_path
|
@@ -5,12 +5,10 @@ Capistrano::Configuration.instance(true).load do
|
|
5
5
|
namespace :sshkey do
|
6
6
|
desc "Sync keys to servers"
|
7
7
|
task :deploy do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
put File.read(CapSshKeyMan::PublicKeyCombiner::AUTHORIZED_KEYS_PATH), File.join("/home/#{user}", ".ssh", "authorized_keys")
|
13
|
-
FileUtils.rm CapSshKeyMan::PublicKeyCombiner::AUTHORIZED_KEYS_PATH # delete temp file after use it.
|
8
|
+
set :sshkeys_path, nil unless exists?(:sshkeys_path)
|
9
|
+
remote_ssh_folder_path = File.join("/home/#{user}", ".ssh", "authorized_keys")
|
10
|
+
put CapSshKeyMan::PublicKeyCombiner.combine_developer_public_keys_in(sshkeys_path), remote_ssh_folder_path
|
11
|
+
run "chmod 600 #{remote_ssh_folder_path}"
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cap-ssh-key-man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 2
|
9
8
|
- 3
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael He
|