feat: allow generating an ssh deploy key via the git plugin
While this might not seem super intuitive, the key is mostly related to git management, not the ssh-keys we currently use to add/remove access to push to dokku.
This commit is contained in:
@@ -34,6 +34,7 @@ fn-help-content() {
|
||||
git:load-image <app> <docker-image> [<git-username> <git-email>], Updates an app's git repository with a docker image loaded from stdin
|
||||
git:sync [--build] <app> <repository> [<git-ref>], Clone or fetch an app from remote git repo
|
||||
git:initialize <app>, Initialize a git repository for an app
|
||||
git:generate-deploy-key, Generates a deploy ssh key
|
||||
git:public-key, Outputs the dokku public deploy key
|
||||
git:report [<app>] [<flag>], Displays a git report for one or more apps
|
||||
git:set <app> <property> (<value>), Set or clear a git property for an app
|
||||
|
||||
@@ -56,6 +56,19 @@ cmd-git-from-archive() {
|
||||
plugn trigger deploy-source-set "$APP" "$ARCHIVE_TYPE" "$ARCHIVE_URL"
|
||||
}
|
||||
|
||||
cmd-git-generate-deploy-key() {
|
||||
declare desc="generates a deploy ssh key"
|
||||
local cmd="git:generate-deploy-key"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
|
||||
if [[ -f "$DOKKU_ROOT/.ssh/id_ed25519.pub" ]] || [[ -f "$DOKKU_ROOT/.ssh/id_rsa.pub" ]]; then
|
||||
dokku_log_exclaim_quiet "A deploy key already exists for this host"
|
||||
return
|
||||
fi
|
||||
|
||||
ssh-keygen -t ed25519 -C "dokku@$(hostname)" -N "" -f "$DOKKU_ROOT/.ssh/id_ed25519"
|
||||
}
|
||||
|
||||
cmd-git-auth() {
|
||||
declare desc="configures netrc authentication for a given git server"
|
||||
local cmd="git:auth"
|
||||
@@ -349,8 +362,8 @@ cmd-git-status() {
|
||||
|
||||
fn-git-auth-error() {
|
||||
dokku_log_warn "There is no deploy key associated with the $DOKKU_SYSTEM_USER user."
|
||||
dokku_log_warn "Generate an ssh key with the following command (do not specify a password):"
|
||||
dokku_log_warn " ssh-keygen -t ed25519 -C 'example@example.com'"
|
||||
dokku_log_warn "Generate an ssh key with the following command:"
|
||||
dokku_log_warn " dokku git:generate-deploy-key"
|
||||
dokku_log_fail "As an alternative, configure the netrc authentication via the git:auth command"
|
||||
}
|
||||
|
||||
|
||||
6
plugins/git/subcommands/generate-deploy-key
Executable file
6
plugins/git/subcommands/generate-deploy-key
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-git-generate-deploy-key "$@"
|
||||
Reference in New Issue
Block a user