dotfiles/.local/bin/scripts/genssh

12 lines
371 B
Bash
Executable File

#!/bin/sh
keys="$HOME/.ssh/keys"
name="${1:-id_ed25519}"
mkdir -p "$keys"
test -f "$keys/$name.pub" || ssh-keygen -t ${2:-ed25519} -b 4096 -f "$keys/$name" -q -N ""
cat "$keys/$name.pub"
if test "$OSTYPE" = "cygwin"
then cat "$keys/$name.pub">/dev/clipboard
else xclip -sel clip 2>/dev/null <"$keys/$name.pub"
fi && echo "SSH Public key copied to clipboard" || return 0