#!/bin/bash # This script updates the authorized_keys file with the keys from the ssh-keys repository. # It assumes that the ssh-keys repository is available on the local machine at the path defined in SSH_KEYS_DIR. # The directory where the ssh-keys repository is located. # TODO: Update this path to the actual location of the ssh-keys repository on the server. SSH_KEYS_DIR="/Users/ten/ssh-keys" # The authorized_keys file to update. AUTHORIZED_KEYS_FILE="$HOME/.ssh/authorized_keys" # The directory containing the public keys. KEYS_DIR="$SSH_KEYS_DIR/keys" # Ensure the .ssh directory exists. mkdir -p "$(dirname "$AUTHORIZED_KEYS_FILE")" # Start with a clean authorized_keys file. > "$AUTHORIZED_KEYS_FILE" # Concatenate all public keys into the authorized_keys file. for key_file in "$KEYS_DIR"/*.pub; do if [ -f "$key_file" ]; then cat "$key_file" >> "$AUTHORIZED_KEYS_FILE" echo "" >> "$AUTHORIZED_KEYS_FILE" # Add a newline after each key fi done echo "SSH keys updated successfully."