Last active
March 20, 2025 15:43
-
-
Save Mez0/bbc217a8cd9b5beff93cd6f4a524e2e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define your SSH public keys here | |
PUBLIC_KEYS=( | |
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAR3QrP/+QYeSAeF5OIEh5H0FJPFbZBVijsgP90Ug9Cq" | |
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINs/phPOQePV+EM4SN8u9n7jrUw2Wg6eHvBholuExmJp Generated By Termius" | |
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMFvJRAIEEUl9LEE4VfriJEkJA13Vpz7l5fUlllcz8DF FS_DE_BIG/Ansible" | |
) | |
# Create the .ssh directory if it doesn't exist | |
mkdir -p ~/.ssh | |
# Create the authorized_keys file if it doesn't exist | |
touch ~/.ssh/authorized_keys | |
# Add the public keys to authorized_keys | |
for KEY in "${PUBLIC_KEYS[@]}"; do | |
# Check if the key is already in the authorized_keys | |
if ! grep -qF "$KEY" ~/.ssh/authorized_keys; then | |
echo "$KEY" >> ~/.ssh/authorized_keys | |
fi | |
done | |
# Set the correct permissions | |
chmod 600 ~/.ssh/authorized_keys | |
chmod 700 ~/.ssh | |
echo "Public keys added to authorized_keys." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment