Configuring Signed Commits on Paradime with SSH Keys
Why Sign Your Commits?
Setup Instructions
Step 1: Create the Setup Script
#!/bin/bash
# Function to check if we're in a git repository
check_git_repo() {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "Error: Not a git repository"
exit 1
fi
}
# Function to generate SSH key
generate_ssh_key() {
local key_comment=$1
if [ -f ~/.ssh/git_signing_key ]; then
echo "Warning: SSH key git_signing_key already exists"
read -p "Do you want to overwrite it? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborting..."
exit 1
fi
fi
ssh-keygen -t ed25519 -C "$key_comment" -f ~/.ssh/git_signing_key -N ""
# Set correct permissions
chmod 600 ~/.ssh/git_signing_key
chmod 644 ~/.ssh/git_signing_key.pub
}
# Function to configure git
configure_git() {
echo -e "\nSetting local git configuration to use the generated signing key.."
git config gpg.format ssh
git config user.signingkey "~/.ssh/git_signing_key.pub"
git config commit.gpgsign true
echo -e "Git configuration complete!\n\n"
}
# Function to display public key
display_key() {
echo "Here's your public key to add to GitHub:"
echo "----------------------------------------"
cat ~/.ssh/git_signing_key.pub
echo "----------------------------------------"
echo "Add this key to GitHub by visiting: https://github.com/settings/keys"
echo "Make sure to choose the key type as 'Signing Key' when adding it. Once done, your setup is complete."
}
# Main script
main() {
check_git_repo
# Get user input
read -p "Enter a comment for your key (e.g., your name, email, etc): " key_comment
# Setup steps
generate_ssh_key "$key_comment"
configure_git
display_key
}
# Run main function
mainStep 2: Make the Script Executable
Step 3: Run the Setup Script
Step 4: Add Your Signing Key to GitHub
Step 5: Verification
Last updated
Was this helpful?