Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ssh key support #343

Merged
merged 3 commits into from
Feb 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ This hook configures the repository `remote` and _push_ the code when the specif
* `remote_repo`: the remote repository to be pushed to.
* `username`: username for repository auth.
* `password`: password for repository auth.
* `pubkey`: publickey for repository auth.
* `privkey`: privatekey for repository auth.

When using groups repositories, each group must have its own `remote` in the `remote_repo` config.

Expand Down
9 changes: 7 additions & 2 deletions lib/oxidized/hook/githubrepo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ def credentials
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')
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

Expand Down