Skip to content

Instantly share code, notes, and snippets.

@droberson
Created April 7, 2020 02:40
Show Gist options
  • Save droberson/7438583d4b25c55736e9a2d6f45b9eeb to your computer and use it in GitHub Desktop.
Save droberson/7438583d4b25c55736e9a2d6f45b9eeb to your computer and use it in GitHub Desktop.
Generate lots of ssh keypairs. This is useful for creating ssh keys to deploy and assign to your teams for CTFs.
#!/bin/sh
# This will generate a keypair for each command line argument:
#
# Create keys named "daniel", "jacob", and "whitley"
# % generate-lots-of-ssh-keypairs.sh daniel jacob whitley
#
# Create 100 numbered keys
# % generate-logs-of-ssh-keypairs.sh $(seq 100)
for name in $@; do
echo | ssh-keygen -f $name -C ${name}@autogenerated >/dev/null -f ~/.ssh/${name} 2>/dev/null
if [ $? != 0 ]; then
echo "[-] Key exists: $name"
else
echo "[+] Created $name"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment