From 495879207cecaa745cc0f03c8b9651ae013f90dc Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 11 Nov 2025 12:58:57 +0900 Subject: [PATCH] Fix SSH PEM key setup script Remove ":" from host name Prepare proper host name without user Set user from hostname part Add command for vim to edit ssh config --- src/bin/create_ssh_config.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bin/create_ssh_config.sh b/src/bin/create_ssh_config.sh index ef9b651..c1bb440 100755 --- a/src/bin/create_ssh_config.sh +++ b/src/bin/create_ssh_config.sh @@ -28,7 +28,9 @@ if [ ! -f "${SSH_CONFIG_BASE}config" ]; then fi; if [[ "${REPOSITORY}" == *":"* ]]; then - REMOTE_HOST=$(echo "${REPOSITORY}" | cut -d ":" -f 1); + REMOTE_USER_HOST=$(echo "${REPOSITORY}" | cut -d ":" -f 1); + REMOTE_HOST=$(echo "${REMOTE_USER_HOST}" | cut -d "@" -f 2); + REMOTE_USER=$(echo "${REMOTE_USER_HOST}" | cut -d "@" -f 1); else echo "[!] Must set a full repository path with remote host for the repository"; error=1; @@ -60,6 +62,7 @@ fi; # ssh-keygen -t ed25519 -N "" -C "${GIT_REPOSITORY_NAME}" -f "${SSH_CONFIG_BASE}${SSH_KEY_NAME}" # must add ".pem" if key name does not end in .pem SSH_COMMAND=("${SUDO_COMMAND[@]}" "ssh-keygen" "-t" "ed25519" "-N" "" "-C" "${GIT_REPOSITORY_NAME}" "-f" "${SSH_CONFIG_BASE}${GIT_REPOSITORY_NAME}.pem") +SSH_CONFIG_COMMAND=("${SUDO_COMMAND[@]}" "vim" "${SSH_CONFIG_BASE}config") # debug output for now echo ""; @@ -69,9 +72,11 @@ echo "${SSH_COMMAND[*]}"; echo ""; echo "* ADD TO: ${SSH_CONFIG_BASE}config"; echo ""; -echo "Host ${GIT_REPOSITORY_NAME}": +echo "${SSH_CONFIG_COMMAND[*]}"; +echo ""; +echo "Host ${GIT_REPOSITORY_NAME}" echo " Hostname ${REMOTE_HOST}"; -echo " User git"; +echo " User ${REMOTE_USER}"; echo " PreferredAuthentications publickey"; echo " IdentityFile ~/.ssh/${GIT_REPOSITORY_NAME}.pem"; if [ -n "${JUMP_PROXY}" ]; then