Skip to content

Commit 059a321

Browse files
committed
feat: add check to prevent overwriting existing SSH key for GitHub
1 parent b502f81 commit 059a321

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

scripts/ubuntu_dev_env_setup.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,23 @@ configure_git() {
191191
echo "Enter your primary email for git:"
192192
read git_email
193193
git config --global user.email "$git_email"
194-
194+
195195
echo "Enter your name for git:"
196196
read git_name
197197
git config --global user.name "$git_name"
198-
199-
echo "Generating SSH key for GitHub..."
200-
ssh-keygen -t rsa -b 4096 -C "$git_email"
201-
eval "$(ssh-agent -s)"
202-
ssh-add ~/.ssh/id_rsa
203-
198+
199+
if [[ ! -f ~/.ssh/id_rsa ]]; then
200+
echo "Generating SSH key for GitHub..."
201+
ssh-keygen -t rsa -b 4096 -C "$git_email"
202+
eval "$(ssh-agent -s)"
203+
ssh-add ~/.ssh/id_rsa
204+
fi
205+
204206
# Refer to Markdown Instructions
205207
echo "Copy your SSH key and add it to GitHub:"
206208
echo "cat ~/.ssh/id_rsa.pub"
207209
}
210+
208211

209212
# Validate networking
210213
validate_network() {

0 commit comments

Comments
 (0)