Skip to content

Instantly share code, notes, and snippets.

@mikemackintosh
Created February 2, 2015 15:40
Show Gist options
  • Save mikemackintosh/1f00c7f703317d1fe5e4 to your computer and use it in GitHub Desktop.
Save mikemackintosh/1f00c7f703317d1fe5e4 to your computer and use it in GitHub Desktop.
Used to generate max-length SSH keys for TMate
#!/bin/bash
gen_key() {
bits=4096
keytype=$1
ks="${keytype}_"
key="keys/ssh_host_${ks}key"
if [ ! -e "${key}" ] ; then
if [ "${keytype}" = 'dsa' ] ; then
bits=1024
elif [ "${keytype}" = 'ecdsa' ] ; then
bits=521
fi
ssh-keygen -t ${keytype} -f "${key}" -b $bits -N ''
return $?
fi
}
mkdir -p keys
gen_key dsa && gen_key rsa && gen_key ecdsa || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment