summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-07-18 13:47:37 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-07-18 13:47:37 +0300
commitff33debbd39a2c2978b0ef7d2d95ea25012e6464 (patch)
treed93694d38588b96f999f3105d0cb8ad7330907f7
parent768ae8ebf263d3ec4929710c51a4d980f55f6b88 (diff)
downloadgitlab-shell-ff33debbd39a2c2978b0ef7d2d95ea25012e6464.tar.gz
Ability to clear authorized_keys file
-rw-r--r--README.md4
-rwxr-xr-xbin/gitlab-keys2
-rw-r--r--lib/gitlab_keys.rb5
3 files changed, 11 insertions, 0 deletions
diff --git a/README.md b/README.md
index 90f532d..c908faf 100644
--- a/README.md
+++ b/README.md
@@ -72,3 +72,7 @@ Remove key
./bin/gitlab-keys rm-key key-23 "ssh-rsa AAAAx321..."
+Remoev all keys from authorized_keys file
+
+ ./bin/gitlab-keys clear
+
diff --git a/bin/gitlab-keys b/bin/gitlab-keys
index 2a8aea1..d402d1e 100755
--- a/bin/gitlab-keys
+++ b/bin/gitlab-keys
@@ -10,6 +10,8 @@ require_relative '../lib/gitlab_init'
#
# /bin/gitlab-keys rm-key key-23 "ssh-rsa AAAAx321..."
#
+# /bin/gitlab-keys clear"
+#
require File.join(ROOT_PATH, 'lib', 'gitlab_keys')
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb
index 03026ed..d09360f 100644
--- a/lib/gitlab_keys.rb
+++ b/lib/gitlab_keys.rb
@@ -17,6 +17,7 @@ class GitlabKeys
case @command
when 'add-key'; add_key
when 'rm-key'; rm_key
+ when 'clear'; clear
else
$logger.warn "Attempt to execute invalid gitlab-keys command #{@command.inspect}."
puts 'not allowed'
@@ -38,4 +39,8 @@ class GitlabKeys
cmd = "sed -i '/shell #{@key_id}\"/d' #{auth_file}"
system(cmd)
end
+
+ def clear
+ system("echo '# Managed by gitlab-shell' > #{auth_file}")
+ end
end