-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_git
executable file
·37 lines (32 loc) · 908 Bytes
/
setup_git
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env zsh
# Generate SSH key in default location (~/.ssh/id_ed25519)
ssh-keygen -t ed25519 -C "[email protected]"
# Start the ssh-agent
eval "$(ssh-agent -s)"
# Create config file with necessary settings
if [[ "$(uname)" == "Darwin" ]]; then
# macOS specific SSH config
cat >~/.ssh/config <<EOF
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
EOF
elif [[ "$(uname)" == "Linux" ]]; then
# Linux specific SSH config
cat >~/.ssh/config <<EOF
Host *
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519
EOF
fi
# Add private key to ssh-agent
if [[ "$OS_TYPE" == "Darwin" ]]; then
ssh-add -K ~/.ssh/id_ed25519
else
ssh-add ~/.ssh/id_ed25519
fi
echo "Git setup is completed ✅"
echo "Please add the following public key to GitHub 🐙"
cat ~/.ssh/id_ed25519.pub
echo "After you add the key execute: 'ssh -T [email protected]' to see whether its working."