{"id":7864,"date":"2025-10-26T10:47:31","date_gmt":"2025-10-26T10:47:31","guid":{"rendered":"https:\/\/focary.app\/blog\/?p=7864"},"modified":"2025-10-26T11:51:22","modified_gmt":"2025-10-26T11:51:22","slug":"how-to-generate-ssh-key-for-github-securely","status":"publish","type":"post","link":"https:\/\/focary.app\/blog\/how-to-generate-ssh-key-for-github-securely\/","title":{"rendered":"9 Steps to Master How to Generate SSH Key for GitHub"},"content":{"rendered":"\n<p>Midway through a deployment. Jenkins pipeline throwing errors. GitHub rejecting pushes. Why? No SSH key. Rookie mistake. <\/p>\n\n\n\n<p>Happens all the time. I\u2019ve been coding, deploying, and securing repos for over 15 years. From bare-metal servers to cloud-native CI\/CD, I\u2019ve seen it all. If you don\u2019t know how to generate SSH key for GitHub properly, you\u2019re leaving the door wide open. <\/p>\n\n\n\n<p>This guide walks you through every step\u2014no fluff, no shortcuts. And yeah, I use <a href=\"https:\/\/focary.app\/\">Focary\u2019s web Pomodoro<\/a> timer to stay locked in while setting up keys across multiple environments. Keeps me focused. Keeps me sane.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Check for Existing SSH Keys<\/h2>\n\n\n\n<p>Before generating anything, check your system. No point duplicating keys or cluttering your <code>.ssh<\/code> directory. Open your terminal and run:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -al ~\/.ssh\n<\/code><\/pre>\n\n\n\n<p>You\u2019re looking for files like <code>id_rsa.pub<\/code>, <code>id_ed25519.pub<\/code>, or any custom-named public keys. If they exist, great. If not, we move forward.<\/p>\n\n\n\n<p>I always name mine with project context. Like <code>id_ed25519_github_main<\/code>\u2014makes it easier when juggling multiple repos. Especially when working with clients who demand isolated access.<\/p>\n\n\n\n<p>And yeah, I use Focary\u2019s Pomodoro timer here. 25-minute sprint to audit keys across machines. No distractions. Just terminal, coffee, and focus.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Generate a New SSH Key<\/h2>\n\n\n\n<p>Now the real work begins. Use <code>ssh-keygen<\/code> to create a new key pair. I prefer Ed25519 over RSA. Faster. More secure. Supported by GitHub.<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-keygen -t ed25519 -C \"your_email@example.com\"\n<\/code><\/pre>\n\n\n\n<p>That <code>-C<\/code> flag? It\u2019s just a label. Helps identify the key later. When prompted, name the file something meaningful. Don\u2019t just hit enter.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter file in which to save the key (\/home\/user\/.ssh\/id_ed25519): \/home\/user\/.ssh\/id_ed25519_github_main\n<\/code><\/pre>\n\n\n\n<p>Add a passphrase. Always. Even if it\u2019s annoying. Security matters. I use Bitwarden to store mine. Encrypted. Synced. Bulletproof.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Add the Key to the SSH Agent<\/h2>\n\n\n\n<p>You don\u2019t wanna type your passphrase every time you push code. That\u2019s where <code>ssh-agent<\/code> comes in. It remembers your key. Keeps it loaded.<\/p>\n\n\n\n<p>Start the agent:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>eval \"$(ssh-agent -s)\"\n<\/code><\/pre>\n\n\n\n<p>Then add your key:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-add ~\/.ssh\/id_ed25519_github_main\n<\/code><\/pre>\n\n\n\n<p>Done. Now your system knows what to do. No more manual entry. No more friction.<\/p>\n\n\n\n<p>I usually do this during my second Pomodoro block. First block is setup. Second is optimization. Focary\u2019s timer keeps me from rushing. Or skipping steps.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Copy the Public Key<\/h2>\n\n\n\n<p>Time to grab the public key and paste it into GitHub. Use:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat ~\/.ssh\/id_ed25519_github_main.pub<\/code><\/pre>\n\n\n\n<p>Copy the output. All of it. Starts with <code>ssh-ed25519<\/code> and ends with your email. Don\u2019t miss a character. One typo and GitHub throws a fit.<\/p>\n\n\n\n<p>I paste it into a temporary markdown file first. Just to double-check formatting. Learned that the hard way after a 2-hour debug session.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Add the Key to GitHub<\/h2>\n\n\n\n<p>Log into GitHub. Go to:<\/p>\n\n\n\n<p><strong>Settings &gt; SSH and GPG keys &gt; New SSH key<\/strong><\/p>\n\n\n\n<p>Paste your public key. Name it something useful. Like \u201cWork Laptop &#8211; Main Repo Access.\u201d Hit save.<\/p>\n\n\n\n<p>Boom. You\u2019re connected.<\/p>\n\n\n\n<p>As GeeksforGeeks explains, SSH keys allow encrypted communication between your machine and GitHub without needing passwords. It\u2019s faster. Safer. Cleaner.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Test the Connection<\/h2>\n\n\n\n<p>Don\u2019t assume it works. Test it.<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -T git@github.com<\/code><\/pre>\n\n\n\n<p>You should see:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hi username! You've successfully authenticated, but GitHub does not provide shell access.<\/code><\/pre>\n\n\n\n<p>If you get a permission denied error, check your key path, agent status, and GitHub settings. Happens more than you\u2019d think.<\/p>\n\n\n\n<p>I keep a <a href=\"https:\/\/localcreative.co\/blog\/notion-to-do-list\/\" target=\"_blank\" rel=\"noopener\">checklist in Notion<\/a>. And yeah, I run this test during my third Pomodoro block. Focary\u2019s timer helps me batch tasks without burning out.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. Configure Git to Use SSH<\/h2>\n\n\n\n<p>Make sure Git uses SSH instead of HTTPS. Run:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git remote set-url origin git@github.com:username\/repo.git<\/code><\/pre>\n\n\n\n<p>Replace <code>username\/repo.git<\/code> with your actual repo path. You can verify with:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git remote -v<\/code><\/pre>\n\n\n\n<p>If you see <code>https:\/\/<\/code>, fix it. SSH is the goal. HTTPS prompts for credentials. SSH doesn\u2019t.<\/p>\n\n\n\n<p>I\u2019ve seen junior devs push to HTTPS for months without realizing. Total time sink. Fix it early.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8. Use Multiple Keys (Advanced)<\/h2>\n\n\n\n<p><a href=\"https:\/\/dev.to\/mr_mornin_star\/how-to-manage-multiple-github-accounts-on-your-machine-using-ssh-53c2\" target=\"_blank\" rel=\"noopener\">Got multiple GitHub accounts<\/a>? You\u2019ll need to configure <code>~\/.ssh\/config<\/code>. Here\u2019s a sample:<\/p>\n\n\n\n<p>C\u00f3digo<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Host github.com-work\n  HostName github.com\n  User git\n  IdentityFile ~\/.ssh\/id_ed25519_work<\/code><\/pre>\n\n\n\n<p>Then clone using:<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone git@github.com-work:username\/repo.git<\/code><\/pre>\n\n\n\n<p>This setup avoids conflicts. Keeps your keys organized. I use it for client work, personal projects, and test environments.<\/p>\n\n\n\n<p>And yes, I configure this during my fourth Pomodoro block. Focary\u2019s timer helps me avoid context-switching. One task. One focus.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. Rotate Keys Periodically<\/h2>\n\n\n\n<p>Security isn\u2019t static. Rotate your keys every 6\u201312 months. Especially if you work in fintech, healthcare, or government.<\/p>\n\n\n\n<p>Delete old keys from GitHub. Generate new ones. Update your agent and config files.<\/p>\n\n\n\n<p>I schedule this quarterly. Focary\u2019s Pomodoro timer makes it manageable. 25 minutes to rotate keys across all machines. No stress. No skipped steps.<\/p>\n\n\n\n<p>As GitHub\u2019s official documentation states, SSH keys are critical for secure authentication. Treat them like passwords. Rotate. Protect. Audit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Generate SSH Key for GitHub<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1000\" height=\"667\" src=\"https:\/\/focary.app\/blog\/wp-content\/uploads\/2025\/10\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub.jpg\" alt=\"9 Steps to Master How to Generate SSH Key for GitHub\" class=\"wp-image-7871\" srcset=\"https:\/\/focary.app\/blog\/wp-content\/uploads\/2025\/10\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub.jpg 1000w, https:\/\/focary.app\/blog\/wp-content\/smush-webp\/2025\/10\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub-300x200.jpg.webp 300w, https:\/\/focary.app\/blog\/wp-content\/smush-webp\/2025\/10\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub-768x512.jpg.webp 768w, https:\/\/focary.app\/blog\/wp-content\/smush-webp\/2025\/10\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub-150x100.jpg.webp 150w, https:\/\/focary.app\/blog\/wp-content\/smush-webp\/2025\/10\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub-450x300.jpg.webp 450w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" data-smush-webp-fallback=\"{&quot;srcset&quot;:&quot;https:\\\/\\\/focary.app\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub.jpg 1000w, https:\\\/\\\/focary.app\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub-300x200.jpg 300w, https:\\\/\\\/focary.app\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub-768x512.jpg 768w, https:\\\/\\\/focary.app\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub-150x100.jpg 150w, https:\\\/\\\/focary.app\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/9-Steps-to-Master-How-to-Generate-SSH-Key-for-GitHub-450x300.jpg 450w&quot;}\" \/><\/figure>\n\n\n\n<p>Hands sweaty. Terminal blinking. You just pushed code to GitHub via SSH. No password prompts. No errors. Just clean, secure authentication.<\/p>\n\n\n\n<p>That\u2019s the feeling. Like nailing a perfect drywall corner. Or watching varnish cure without bubbles. Satisfaction.<\/p>\n\n\n\n<p>Learning how to generate SSH key for GitHub isn\u2019t just technical. It\u2019s foundational. It\u2019s the difference between amateur and pro. Between friction and flow.<\/p>\n\n\n\n<p>And if you\u2019re juggling multiple environments, repos, or clients\u2014use Focary\u2019s web Pomodoro timer. It\u2019s free. It\u2019s simple. It keeps your brain locked in when the terminal starts throwing curveballs.<\/p>\n\n\n\n<p>Because in this game, focus isn\u2019t optional. It\u2019s everything.<\/p>\n\n\n\n<p><strong>Sources:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.github.com\/en\/authentication\/connecting-to-github-with-ssh\/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent\" target=\"_blank\" rel=\"noopener\">GitHub Docs: Generating a new SSH key<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.geeksforgeeks.org\/git\/how-to-add-ssh-key-to-your-github-account\/\" target=\"_blank\" rel=\"noopener\">GeeksforGeeks: How to Add SSH Key to GitHub<\/a><\/li>\n<\/ul>\n\n\n","protected":false},"excerpt":{"rendered":"<p>Midway through a deployment. Jenkins pipeline throwing errors. GitHub rejecting pushes. Why? No SSH key. Rookie mistake. Happens all the time. I\u2019ve been coding, deploying, and securing repos for over 15 years. From bare-metal servers to cloud-native CI\/CD, I\u2019ve seen it all. If you don\u2019t know how to generate SSH key for GitHub properly, you\u2019re<\/p>\n","protected":false},"author":1,"featured_media":7870,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[245],"tags":[244,239,242,235,237,241,243,240,236,238],"class_list":{"0":"post-7864","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-development-tools","8":"tag-developer-tools","9":"tag-git-security","10":"tag-github-access","11":"tag-github-authentication","12":"tag-github-ssh-tutorial","13":"tag-secure-git-workflow","14":"tag-ssh-best-practices","15":"tag-ssh-key-generation","16":"tag-ssh-key-github","17":"tag-ssh-setup"},"jetpack_featured_media_url":"https:\/\/focary.app\/blog\/wp-content\/uploads\/2025\/10\/How-to-Generate-SSH-Key-for-GitHub.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/posts\/7864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/comments?post=7864"}],"version-history":[{"count":4,"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/posts\/7864\/revisions"}],"predecessor-version":[{"id":7886,"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/posts\/7864\/revisions\/7886"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/media\/7870"}],"wp:attachment":[{"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/media?parent=7864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/categories?post=7864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/focary.app\/blog\/wp-json\/wp\/v2\/tags?post=7864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}