summaryrefslogtreecommitdiff
path: root/lib/oxidized/hook
diff options
context:
space:
mode:
authorawlx <awlnx@penguinfriends.org>2016-02-25 13:50:39 +0100
committerawlx <awlnx@penguinfriends.org>2016-02-25 13:50:39 +0100
commit916b053dca5436ebd147111c466be06b9e3f9f84 (patch)
treeeff28a9e2e9c41e1affb6e7ef47e917e54f7708e /lib/oxidized/hook
parent604fe69d24a42881244b37a9368a745f3335989b (diff)
Added support for SSH Key usage and ssh-agent-forwarding
Diffstat (limited to 'lib/oxidized/hook')
-rw-r--r--lib/oxidized/hook/githubrepo.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb
index 7fc6677..b959f6d 100644
--- a/lib/oxidized/hook/githubrepo.rb
+++ b/lib/oxidized/hook/githubrepo.rb
@@ -49,8 +49,13 @@ class GithubRepo < Oxidized::Hook
log "Using https auth", :debug
Rugged::Credentials::UserPassword.new(username: cfg.username, password: cfg.password)
else
- log "Using ssh auth", :debug
- Rugged::Credentials::SshKeyFromAgent.new(username: 'git')
+ @credentials ||= if cfg.has_key?('pubkey') && cfg.has_key?('privkey')
+ log "Using ssh auth with key", :debug
+ Rugged::Credentials::SshKey.new(username: 'git', publickey: File.expand_path(cfg.pubkey), privatekey: File.expand_path(cfg.privkey))
+ else
+ log "Using ssh auth with agentforwarding", :debug
+ Rugged::Credentials::SshKeyFromAgent.new(username: 'git')
+ end
end
end