Skip to content

Instantly share code, notes, and snippets.

@o0-o
Last active May 7, 2019 02:27
Show Gist options
  • Select an option

  • Save o0-o/48dd41ab289e5b4324c246af4fc8df2d to your computer and use it in GitHub Desktop.

Select an option

Save o0-o/48dd41ab289e5b4324c246af4fc8df2d to your computer and use it in GitHub Desktop.
[Create SSH Key] Generate and install an SSH key #Shell
# ssh_key_create.sh
#
# parameter: user@host
# example: [email protected]
( # try ed25519
( ssh-keygen -t ed25519 -b 4096 -f "~/.ssh/$1" &&
ssh-copy-id -i ~/.ssh/"$1" "$1"
) ||
# fallback to rsa
( ssh-keygen -t rsa -b 4096 -f "~/.ssh/$1"
ssh-copy-id -i ~/.ssh/"$1" "$1"
)
) 2>/dev/null ||
exit 1 #failure
exit 0 #success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment