How to use multiple RSA (SSH) keys for GitHub

CK CK 3788 
Created at  
328 0 0

When you use multiple RSA (SSH) keys for GitHub, you need to configure them properly so Git knows which key to use for which repository. This is common when you have multiple GitHub accounts (e.g., personal and work).

Here’s how you can do it:

1. Generate Multiple SSH Keys

If you don’t already have them:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com" 

When prompted for filename, give each key a unique name:

~/.ssh/id_rsa_github_personal
~/.ssh/id_rsa_github_work

 

2. Add Keys to SSH Agent

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa_github_personal
ssh-add ~/.ssh/id_rsa_github_work

 

3. Configure SSH (~/.ssh/config)

Edit or create the SSH config file:

nano ~/.ssh/config

Add entries for each GitHub account:

# Personal GitHub
Host github-personal
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_github_personal

# Work GitHub
Host github-work
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_github_work

 

4. Use the Correct Host in Your Git Remote

When cloning or setting remotes, use the alias (github-personal or github-work):

# Personal repo
git clone git@github-personal:username/repo.git

# Work repo
git clone git@github-work:company/repo.git

If the repo is already cloned, update the remote:

git remote set-url origin git@github-work:company/repo.git

 

5. Test Your Config

ssh -T git@github-personal
ssh -T git@github-work

You should see GitHub greeting you with the correct username for each.

Tags GitHub RSA RSA Keys SSH Keys Facebook X
Comments 0
Similar posts
  1. You shouldn't use Amazon CloudFront distribution as an origin
    633
  2. Contributing to the Ethereum Foundation
    3,536
  1. Arm Kernel DNNs: Powering Efficient AI at the Edge
    224
  2. Cloud-Native Capital Markets: Architecture, Compliance, and Innovation
    213
  3. Add New Address to gmail without SMTP (forwarding-only-address)
    1,677
  4. Registering an App on the Google Play Store
    1,459
  5. AGENT.md: AI's Blueprint for Robust Software and Vibe Coding
    551
  6. Tailscale: Zero-Config Remote Access to Your Home PC, Firewall-Free
    532
  7. Markdown's Visual Revolution: Meet Mermaid.js
    410
  8. Viewing Git Graph in ASCII
    588
  9. Vibe Coding: Harmonizing Intent with AI Productivity
    497
  10. How do I change the theme for code block in Confluence Cloud?
    1,369
  11. FIPS - Federal Information Processing Standards
    1,392
  12. Simplify Your Workflow: Switching Git Profiles Automatically by Folder
    749
  13. How to Control External Monitor Brightness, Sound Volume on a Mac with MonitorControl (Even Over HDMI)
    2,393
  14. Building Multilingual Applications with i18n
    1,197
  15. Kiro versus Cursor AI - Spec-Driven? or Chat-Driven?
    401
  16. Key Metrics Track to Ensure the Health and Performance of a Distributed System
    175
  17. REST API Vs. GraphQL
    409
  18. Project Libre similar to MS Project
    528
  19. Learning about Firestore: Architecture, Pros, Cons, and Real-World Deployments
    167
  20. Building Privacy-First Infrastructure: Network Isolation + Zero Trust for GDPR Compliance
    292
  21. Why supabase is not safe for the Fintech project?
    855
  22. The Ultimate Data Engineering Roadmap
    1,070
  23. Nine Types of Testing while we develop APIs
    512
  24. Apache Kafka - a distributed, fault-tolerant, high-throughput streaming platform
    614
  25. Comprehensive Software Development Flow : How Companies Ship Code To Production
    2,312
  26. DeepSeek v3 offers of ChatGPT's performance at 1/10 the price!
    633
  27. Difference between CPU and GPU - Why GPU is faster than CPU?
    803
  28. gRPC - Open-source Universal RPC Framework developed by Google
    767
  29. Exploring the Depths of Data Transfer: sendfile vs. kTLS
    1,320
  30. How Netflix Ensures Smooth Streaming with Open Connect CDN
    2,129
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    39
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    34
  3. How do I create animated background for Google Meet?
    20,611
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    244
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    514
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    287
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    230
  16. TPU & GPU Cluster Management Tools
    243
  17. The Concept of Scaffolding in AI Agents
    233
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    582
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    258
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    338
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    221
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    220
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    195
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    216
  30. Understanding Data Lineage
    260