Skip to content

Instantly share code, notes, and snippets.

@bpmooch
Created June 4, 2020 02:05
Show Gist options
  • Select an option

  • Save bpmooch/58a17e7590a098428a1882235073cdd7 to your computer and use it in GitHub Desktop.

Select an option

Save bpmooch/58a17e7590a098428a1882235073cdd7 to your computer and use it in GitHub Desktop.
create rsa ssh key and copy the key pub to your clipboard
#!/bin/bash
# generate key
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f "$HOME/.ssh/id_rsa" -P "" -q
# start ssh agent
RESULT=$(eval "$(ssh-agent -s)")
echo $RESULT
# add key to ssh-agent
ssh-add ~/.ssh/id_rsa
# install xclip if its not available
if ! [ -f xclip ] ; then
sudo apt-get update
sudo apt-get install xclip
fi
KEY_PUB=~/.ssh/id_rsa.pub
xclip -sel clip < $KEY_PUB
echo "The contents of $KEY_PUB have been copied to your clipboard"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment