Last active
September 28, 2024 02:07
-
-
Save eplord/86a0c32baa5e45d345917184874685ac to your computer and use it in GitHub Desktop.
generate ssh bash script
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
| #!/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