This commit is contained in:
2026-04-22 19:10:09 +02:00
parent 62f1bd1b75
commit 49df2bdf74

View File

@@ -78,9 +78,9 @@ prompt_passphrase() {
local pass2="" local pass2=""
while true; do while true; do
read -r -s -p "Enter SSH key passphrase: " pass1 IFS= read -r -s -p "Enter SSH key passphrase: " pass1
printf '\n' printf '\n'
read -r -s -p "Confirm SSH key passphrase: " pass2 IFS= read -r -s -p "Confirm SSH key passphrase: " pass2
printf '\n' printf '\n'
if [[ "$pass1" == "$pass2" ]]; then if [[ "$pass1" == "$pass2" ]]; then
@@ -121,6 +121,28 @@ extract_host_from_git_url() {
return 1 return 1
} }
add_host_to_known_hosts() {
local host="$1"
if [[ -z "$host" ]]; then
return 1
fi
if ! command_exists ssh-keyscan; then
warn "ssh-keyscan is not installed; skipping known_hosts update for $host"
return 1
fi
mkdir -p "$HOME_DIR/.ssh"
touch "$HOME_DIR/.ssh/known_hosts"
if ssh-keygen -F "$host" -f "$HOME_DIR/.ssh/known_hosts" >/dev/null 2>&1; then
return 0
fi
ssh-keyscan -H "$host" >>"$HOME_DIR/.ssh/known_hosts" 2>/dev/null || true
}
install_pacman_package() { install_pacman_package() {
local package="$1" local package="$1"
sudo pacman -S --needed --noconfirm "$package" sudo pacman -S --needed --noconfirm "$package"
@@ -276,10 +298,7 @@ if prompt_yes_no "Create or reuse an SSH key for git access?" "Y"; then
if prompt_yes_no "Add a git host to ~/.ssh/known_hosts?" "Y"; then if prompt_yes_no "Add a git host to ~/.ssh/known_hosts?" "Y"; then
git_host="$(prompt_required_value "Git host (for ssh-keyscan):")" git_host="$(prompt_required_value "Git host (for ssh-keyscan):")"
if command_exists ssh-keyscan; then add_host_to_known_hosts "$git_host"
touch "$HOME_DIR/.ssh/known_hosts"
ssh-keyscan -H "$git_host" >>"$HOME_DIR/.ssh/known_hosts" 2>/dev/null || true
fi
fi fi
if prompt_yes_no "Copy the public SSH key to the clipboard?" "Y"; then if prompt_yes_no "Copy the public SSH key to the clipboard?" "Y"; then
@@ -314,18 +333,18 @@ if prompt_yes_no "Clone a dotfiles repository into ~/.config?" "Y"; then
fi fi
if [[ -n "$dotfiles_repo" ]]; then if [[ -n "$dotfiles_repo" ]]; then
if dotfiles_host="$(extract_host_from_git_url "$dotfiles_repo")"; then
if prompt_yes_no "Add the dotfiles git host to ~/.ssh/known_hosts before cloning?" "Y"; then
add_host_to_known_hosts "$dotfiles_host"
fi
fi
git clone "$dotfiles_repo" "$config_target" git clone "$dotfiles_repo" "$config_target"
if prompt_yes_no "Add the dotfiles git host to ~/.ssh/known_hosts?" "Y"; then if ! dotfiles_host="$(extract_host_from_git_url "$dotfiles_repo")"; then
if dotfiles_host="$(extract_host_from_git_url "$dotfiles_repo")"; then
mkdir -p "$HOME_DIR/.ssh"
touch "$HOME_DIR/.ssh/known_hosts"
ssh-keyscan -H "$dotfiles_host" >>"$HOME_DIR/.ssh/known_hosts" 2>/dev/null || true
else
warn "Could not determine a host from '$dotfiles_repo'" warn "Could not determine a host from '$dotfiles_repo'"
fi fi
fi fi
fi
fi fi
if prompt_yes_no "Clone a wallpapers repository?" "Y"; then if prompt_yes_no "Clone a wallpapers repository?" "Y"; then