How to generate SSH keys for GitHub

Generating SSH keys for GitHub provides secure, passwordless authentication for repository access without entering credentials repeatedly. As the creator of CoreUI with over 25 years of development experience, I’ve configured GitHub SSH access for countless developers and teams. The most effective solution is to generate an SSH key pair with ssh-keygen and add the public key to your GitHub account. This approach provides strong cryptographic authentication and streamlines your Git workflow.

Generate SSH keys and add them to GitHub for secure authentication.

# Generate new SSH key for GitHub
ssh-keygen -t ed25519 -C '[email protected]'

# Press Enter to accept default location (~/.ssh/id_ed25519)
# Enter a secure passphrase when prompted

# Start SSH agent
eval "$(ssh-agent -s)"

# Add SSH key to agent
ssh-add ~/.ssh/id_ed25519

# Copy public key to clipboard (macOS)
pbcopy < ~/.ssh/id_ed25519.pub

# Copy public key to clipboard (Linux)
xclip -selection clipboard < ~/.ssh/id_ed25519.pub

# Copy public key to clipboard (Windows/Git Bash)
cat ~/.ssh/id_ed25519.pub | clip

# Or display the key to copy manually
cat ~/.ssh/id_ed25519.pub

After generating the key, go to GitHub Settings > SSH and GPG keys > New SSH key. Paste your public key, give it a descriptive title, and save. Test the connection with ssh -T [email protected]. You should see a success message. Now you can clone repositories using SSH URLs and push/pull without entering passwords.

Best Practice Note

This is the same SSH key setup we use for CoreUI team members accessing GitHub repositories. Always protect your private key with a strong passphrase and never share it. Use different SSH keys for different services or organizations for better security isolation. The ed25519 algorithm is modern and secure, but use RSA 4096-bit if ed25519 isn’t supported.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
How to Remove Underline from Link in CSS
How to Remove Underline from Link in CSS

How to Convert a Map to an Array in JavaScript
How to Convert a Map to an Array in JavaScript

How to Use Bootstrap Tooltip in Vue 3 – The Right Way with CoreUI
How to Use Bootstrap Tooltip in Vue 3 – The Right Way with CoreUI

How to get element ID in JavaScript
How to get element ID in JavaScript

Answers by CoreUI Core Team