Skip to content

Instantly share code, notes, and snippets.

@eplord
Last active September 28, 2024 02:07
Show Gist options
  • Select an option

  • Save eplord/86a0c32baa5e45d345917184874685ac to your computer and use it in GitHub Desktop.

Select an option

Save eplord/86a0c32baa5e45d345917184874685ac to your computer and use it in GitHub Desktop.
generate ssh bash script
#!/bin/sh
# https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
# download this script an make it executable with `chmod +x create_ssh
if [ -n "$1" ]; then
COMMENT=$1
else
COMMENT=$USER
fi
if [ -n "$2" ]; then
IDENTIFIER=$2
else
IDENTIFIER=$(date +"%Y%m%dT%H%M%S")
fi
if [ -n "$3" ]; then
TARGET=$3
else
TARGET=$HOME/.ssh
fi
ssh-keygen -t ed25519 -C "${COMMENT}" -f "${TARGET}/${IDENTIFIER}_ed25519"
echo "copy/paste the text below this line when adding the key to your account"
echo "----------"
cat "${TARGET}/${IDENTIFIER}_ed25519.pub"
echo "----------"
echo "copy/paste the text above this line when adding the key to your account"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment