The real GitHub SSH Setup & Workflow - Command Line Demo
GitHub SSH Setup & Workflow - Step by Step Guide
🔑 Step 1: Generate SSH Key Pair
Open Command Prompt and navigate to your directory
cd C:\temp\_demo
Generate SSH key with RSA 4096-bit encryption
ssh-keygen -t rsa -b 4096 -C "[email protected]"
When prompted for file location, enter:
C:\temp\_demo\mytest
Leave passphrase empty (or set one for security)
📋 Step 2: View Public Key
Display your public key to copy it
type mytest.pub
🌐 Step 3: Add SSH Key to GitHub
Go to GitHub.com
Click your profile → Settings → SSH and GPG keys
Click New SSH Key
Enter details:
Title: TestingKey
Key: Paste your entire public key (from Step 2)
Click Add SSH Key
Login if prompted
📥 Step 4: Clone Repository
Go to your GitHub repository page
Click Code → HTTPS
Copy the URL to clipboard
Clone the repository:
git clone https://github.com/yourusername/test.git
🛠️ Step 5: Make Changes
Navigate to project directory:
cd ./test
Make your code changes (add files, modify code, etc.)
📤 Step 6: Push Changes to GitHub
Check what files have changed
git status
Stage all changes for commit
git add .
Commit changes with a message
git commit -m "Backup"
Push changes to GitHub main branch
git push origin main
💡 Pro Tips & Notes
SSH vs HTTPS Clarification:
SSH Keys are for authentication but we used HTTPS for cloning
To use SSH authentication, clone with: git clone [email protected]:username/repo.git
Or switch existing repo: git remote set-url origin [email protected]:username/repo.git
Troubleshooting:
If git push asks for credentials, use GitHub Personal Access Token
Ensure your public key was copied completely (starts with ssh-rsa...)
Verify SSH key is added correctly in GitHub Settings
Files Created:
mytest - Private key (keep this secure!)
mytest.pub - Public key (share this with GitHub)
test/ - Cloned repository directory
📚 Useful Git Commands
Check repository status
git status
View commit history
git log
Check remote repository URL
git remote -v
Switch from HTTPS to SSH
git remote set-url origin [email protected]:username/repo.git
#github #git