Created
June 4, 2020 02:05
-
-
Save bpmooch/58a17e7590a098428a1882235073cdd7 to your computer and use it in GitHub Desktop.
create rsa ssh key and copy the key pub to your clipboard
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/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