-
-
Save pkavoo/a6a80d96d8f54f592827dbde96fc08bd to your computer and use it in GitHub Desktop.
ssh_configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Generate a New SSH Key Pair | |
| Open your terminal (or Git Bash on Windows) and run the following command. The ed25519 algorithm is the recommended standard for security. | |
| Bash | |
| ssh-keygen -t ed25519 -C "[email protected]" | |
| Replace "[email protected]" with the email address associated with your GitHub account. | |
| Prompt 1 (File location): Press Enter to accept the default location (usually ~/.ssh/id_ed25519). If you already have a key, it's best to enter a new name (e.g., ~/.ssh/github_id_ed25519). | |
| Prompt 2 (Passphrase): Enter a secure passphrase to protect your private key (recommended for extra security). You will be prompted to enter this passphrase when you use the key. Press Enter twice if you do not want a passphrase. | |
| This creates two files in the .ssh directory: | |
| id_ed25519: Your private key (keep this secret and safe). | |
| id_ed25519.pub: Your public key (this is what you share with GitHub). | |
| 2. Start the SSH Agent and Add Your Key | |
| The SSH agent manages your keys and holds them in memory so you don't have to enter the passphrase repeatedly. | |
| Start the ssh-agent: | |
| Linux/macOS/Git Bash (Windows):Basheval "$(ssh-agent -s)" | |
| PowerShell (Windows):PowerShellStart-Service ssh-agent | |
| Add your private key to the agent: | |
| Bash | |
| ssh-add ~/.ssh/id_ed25519 | |
| If you created a passphrase, you'll be prompted to enter it now. | |
| If your key has a different name (e.g., github_id_ed25519), replace id_ed25519 with your key's filename. | |
| 3. Add the Public Key to GitHub | |
| You must copy the contents of your public key file and paste it into your GitHub settings. | |
| Copy the Public Key: | |
| macOS:Bashpbcopy < ~/.ssh/id_ed25519.pub | |
| Linux (Requires xclip or similar):Bashcat ~/.ssh/id_ed25519.pub | xclip -selection clipboard | |
| Windows (Git Bash):Bashclip < ~/.ssh/id_ed25519.pub | |
| Manual Method (Any OS): Open the public key file (~/.ssh/id_ed25519.pub) with a text editor and copy the entire content. It starts with ssh-ed25519 and ends with your email/comment. | |
| Add to GitHub: | |
| Log into GitHub. | |
| Click your profile photo in the upper-right corner, then click Settings. | |
| In the left sidebar, click SSH and GPG keys. | |
| Click New SSH key. | |
| Provide a Title (e.g., "My Laptop"). | |
| Paste your copied public key content into the Key field. | |
| Click Add SSH key. | |
| 4. Test the Connection and Update Repositories | |
| Test the connection: | |
| Run this command in your terminal: | |
| Bash | |
| ssh -T [email protected] | |
| Successful message: You should see a message like: Hi <username>! You've successfully authenticated, but GitHub does not provide shell access. | |
| Failure message: If you get a "Permission denied" error, re-check steps 2 and 3. | |
| Update existing repositories: | |
| If you have local repositories cloned using the HTTPS URL, you need to change them to use the SSH URL: | |
| Bash | |
| # Check the current remote URL | |
| git remote -v | |
| # Change the remote URL (replace username/repo.git with your actual path) | |
| git remote set-url origin [email protected]:USERNAME/REPO.git | |
| From now on, when cloning new repositories, use the SSH URL (which starts with [email protected]:). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment