Skip to content

Instantly share code, notes, and snippets.

@maivdigital
Created January 5, 2021 03:44
Show Gist options
  • Save maivdigital/5df29242946108f263aaf3a153f69ec8 to your computer and use it in GitHub Desktop.
Save maivdigital/5df29242946108f263aaf3a153f69ec8 to your computer and use it in GitHub Desktop.
Generate SSH key bash
#!/bin/bash
echo -e "====== Starting SSH Agent =======\n\n";
eval "$(ssh-agent)";
echo -e "====== Continue with the default, just hit enter =========\n\n";
ssh-keygen -t rsa -b 4096
echo -e "======= Generating SSH Key is done and saved at ~/.ssh/id_rsa ==========\n\n";
cat ~/.ssh/id_rsa.pub
echo -e "\n";
echo -e "====== Copy the content of public key and paste into your Repo ============\n\n"
@maivdigital
Copy link
Author

maivdigital commented Apr 2, 2021

#!/bin/bash

#Updated version

#Run SSH Agent once
runcount=$(ps -ef | grep "ssh-agent" | grep -v "grep" | wc -l)
if [ $runcount -eq 0 ]; then
echo -e "====== Starting SSH Agent =======\n\n";
eval "$(ssh-agent)";
echo -e "====== Continue with the default, just hit enter =========\n\n";
ssh-keygen -t rsa -b 4096
echo -e "======= Generating SSH Key is done and saved at ~/.ssh/id_rsa ==========\n\n";
cat ~/.ssh/id_rsa.pub
echo -e "\n";
echo -e "====== Copy the content of public key and paste into your Repo ============\n\n"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment