forked from likeajumprope/HPC_DRA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_ssh_key.sh
35 lines (28 loc) · 1.17 KB
/
generate_ssh_key.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
#!/bin/bash
# Prompt for email address
echo "Enter your email address/identifier for the SSH key (e.g., [email protected]):"
read email
# Set the file path for the SSH key
ssh_key_path="$HOME/.ssh/id_rsa_github"
# Generate SSH key
echo "Generating SSH key..."
ssh-keygen -t rsa -b 4096 -C "$email" -f "$ssh_key_path" -N ""
# Start the SSH agent
echo "Starting the SSH agent..."
eval "$(ssh-agent -s)"
# Add the SSH key to the agent
echo "Adding the SSH key to the SSH agent..."
ssh-add "$ssh_key_path"
# Display the public key
echo "Your SSH public key has been generated. Copy it and add it to your Git hosting platform."
echo "---------------------------------------------------"
cat "${ssh_key_path}.pub"
echo "---------------------------------------------------"
# Suggest next steps
echo "Next steps:"
echo "1. Copy the above key and add it to your Git hosting platform (GitHub, GitLab, etc.)."
echo " - For GitHub: https://github.com/settings/SSH and GPC keys"
echo " - For GitLab: https://gitlab.com/-/profile/keys"
echo "2. Test the connection to your Git host using:"
echo " ssh -T [email protected]"
echo " (Replace 'github.com' with your Git hosting platform if different.)"