Skip to content

Instantly share code, notes, and snippets.

@neitsab
Last active April 1, 2026 15:38
Show Gist options
  • Select an option

  • Save neitsab/d2a33d054c7d69da1876fe534eab2aa5 to your computer and use it in GitHub Desktop.

Select an option

Save neitsab/d2a33d054c7d69da1876fe534eab2aa5 to your computer and use it in GitHub Desktop.
KodeKloud 100 Days of DevOps helper scripts
#!/usr/bin/env bash
# This script sets up passwordless SSH and sudo on the app servers
# Data from https://kodekloudhub.github.io/kodekloud-engineer/docs/projects/nautilus#infrastructure-details
# Generate an SSH key pair
ssh-keygen -t ed25519 -f "$HOME/.ssh/id_ed25519" -N ""
# Disable SSH client strict host key checking
sudo -S sed -i "/StrictHostKeyChecking/s/^#//;s/ask/no/" /etc/ssh/ssh_config <<< mjolnir123
# Array variable with the credentials for the 3 App Servers
declare -A HOSTS=(
["tony@stapp01"]="Ir0nM@n"
["steve@stapp02"]="Am3ric@"
["banner@stapp03"]="BigGr33n"
)
# loop to set up the generated public key on the 3 App Servers & set up passwordless sudo there
for USERHOST in "${!HOSTS[@]}"; do
PASSWORD="${HOSTS[$USERHOST]}"
sshpass -p "$PASSWORD" ssh-copy-id "$USERHOST"
ssh "$USERHOST" "echo '$PASSWORD' | sudo -S bash -c 'echo %wheel ALL=\(ALL\) NOPASSWD: ALL > /etc/sudoers.d/nopasswd'"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment