-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_github_ssh.sh
executable file
·52 lines (41 loc) · 1.38 KB
/
setup_github_ssh.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# GitHub SSH Keys Setup Script
# Variables
EMAIL="[email protected]" # Change this to your email
# Step 1: Generate SSH Key
echo "Generating SSH key..."
ssh-keygen -t ed25519 -C "$EMAIL" -f ~/.ssh/id_ed25519 -N ""
# Step 2: Start the SSH Agent
echo "Starting the SSH agent..."
eval "$(ssh-agent -s)"
# Step 3: Create SSH Config File if it doesn't exist
SSH_CONFIG="$HOME/.ssh/config"
if [ ! -f "$SSH_CONFIG" ]; then
echo "Creating SSH config file..."
touch "$SSH_CONFIG"
fi
# Step 4: Configure SSH
echo "Configuring SSH..."
{
echo "Host *"
echo " AddKeysToAgent yes"
echo " IdentityFile ~/.ssh/id_ed25519"
# echo " UseKeychain yes" # Uncomment this line if using macOS
} >> "$SSH_CONFIG"
# Step 5: Add SSH Key to the Agent
echo "Adding SSH key to the agent..."
ssh-add ~/.ssh/id_ed25519
# Step 6: Display the public key
echo "Your public SSH key (copy this to GitHub):"
cat ~/.ssh/id_ed25519.pub
# Instructions for the user
echo ""
echo "Please log into GitHub, go to Settings > SSH and GPG Keys, and add your SSH key."
echo "1. Title Your Key: Enter a name for the key."
echo "2. Paste the Key: Copy the contents from above and paste them into the key field on GitHub."
echo "3. Click Add SSH Key and enter your password when prompted."
# Test the SSH connection
echo ""
echo "Testing your SSH key..."
ssh -T [email protected]
echo "SSH key setup is complete!"