Overview
GitHub Desktop provides secure authentication for various Git hosting services, including GitHub.com, GitHub Enterprise Server, and generic Git servers. Authentication enables cloning private repositories, pushing changes, and creating pull requests.OAuth for GitHub
Secure OAuth 2.0 authentication for GitHub services
Personal Access Tokens
Token-based authentication for Git operations
SSH Support
Use SSH keys for authentication
Credential Storage
Secure storage using OS credential managers
GitHub Authentication
OAuth Sign-In
GitHub Desktop uses OAuth 2.0 for authenticating with GitHub:1
Initiate Sign-In
Click File > Options > Accounts > Sign in (GitHub.com or Enterprise)
2
Browser Opens
Your default browser opens to GitHub’s authorization page
3
Authorize Application
Review permissions and click Authorize desktop
4
Return to Desktop
Browser redirects back to GitHub Desktop with a token
5
Complete
You’re signed in and can access your repositories
OAuth Scopes
GitHub Desktop requests these OAuth scopes:-
repo: Full control of private repositories- Read and write repository data
- Create pull requests
- Access commit status
-
read:org: Read organization membership- List organization repositories
- View organization membership
-
user:email: Access user email addresses- Get commit email address
- Match commits to user
-
workflow: Update GitHub Actions workflows- Modify workflow files
- Trigger workflow runs
OAuth tokens are stored securely in your operating system’s credential manager (Credential Manager on Windows, Keychain on macOS, libsecret on Linux).
Authentication Key Storage
From the source code:GitHub - https://api.github.comGitHub - https://github.example.com/api/v3
GitHub Enterprise Authentication
Adding Enterprise Server
1
Open Accounts
File > Options > Accounts
2
Sign in to Enterprise
Click Sign in next to “GitHub Enterprise Server”
3
Enter Server URL
Enter your Enterprise server address:
4
Authenticate
Complete OAuth flow on your Enterprise server
Enterprise Requirements
- GitHub Enterprise Server 2.15 or later
- OAuth application must be registered
- Network access to the server
- Valid SSL certificate (or exception configured)
Multiple Enterprise Servers
You can connect to multiple Enterprise servers:- Each server requires separate sign-in
- Separate OAuth tokens for each
- Switch between servers when cloning/creating PRs
Generic Git Authentication
For non-GitHub Git servers (GitLab, Bitbucket, self-hosted, etc.):Username and Password
GitHub Desktop can store credentials for generic Git servers:When Credentials Are Requested
GitHub Desktop prompts for credentials when:- Cloning a repository from a non-GitHub URL
- Pushing to a remote that requires authentication
- Fetching from a private repository
- Username field
- Password/token field
- “Remember credentials” checkbox
Personal Access Tokens
Creating GitHub Tokens
1
Open GitHub Settings
Go to GitHub.com > Settings > Developer settings > Personal access tokens > Tokens (classic)
2
Generate New Token
Click Generate new token (classic)
3
Set Scopes
Select scopes:
- ✓
repo(full control of private repositories) - ✓
workflow(update workflows) - ✓
read:org(read org membership)
4
Generate
Click Generate token and copy the token immediately
5
Use in Desktop
Sign in to GitHub Desktop using OAuth (tokens are automatically managed)
Token Expiration
GitHub tokens can expire:- GitHub recommends setting expiration dates
- GitHub Desktop will prompt for re-authentication when token expires
- Sign in again to refresh the token
SSH Authentication
Using SSH Keys
GitHub Desktop supports SSH authentication:1
Generate SSH Key
2
Add to SSH Agent
3
Add to GitHub
Copy public key:Add to GitHub: Settings > SSH and GPG keys > New SSH key
4
Use SSH URLs
Clone repositories using SSH URLs:
SSH vs HTTPS
- HTTPS (Recommended)
- SSH
Pros:
- Works through most firewalls
- No SSH key setup required
- Easier for beginners
- GitHub Desktop handles tokens automatically
- Requires token or OAuth
- Some corporate proxies may inspect traffic
GitHub Desktop works with both HTTPS and SSH remotes. However, OAuth authentication only applies to HTTPS. SSH uses your SSH keys managed by
ssh-agent.Credential Storage
Operating System Integration
GitHub Desktop uses the OS credential manager:- Windows
- macOS
- Linux
Windows Credential ManagerCredentials stored in:
- Control Panel > Credential Manager
- Windows Credentials > Generic Credentials
GitHub - https://api.github.comgenericGitAuth/username/https://gitlab.com
- Open Credential Manager
- Find GitHub Desktop entries
- Edit or remove as needed
Token Lifetime
Tokens are stored until:- You sign out of GitHub Desktop
- You manually remove from credential manager
- Token expires (GitHub tokens)
- Revoked on GitHub.com/Enterprise
Two-Factor Authentication (2FA)
GitHub 2FA Support
GitHub Desktop fully supports 2FA:1
Sign In
Start the OAuth sign-in process
2
Enter Password
Enter your GitHub password
3
2FA Prompt
Enter your 2FA code:
- Authenticator app code
- SMS code
- Security key
4
Authorize
Complete authorization
Once authorized with OAuth, you don’t need to enter 2FA codes for each Git operation. The OAuth token handles authentication.
2FA with HTTPS Git
If using HTTPS without OAuth:- Password authentication is disabled for 2FA accounts
- Must use a personal access token instead
- Create token on GitHub.com > Settings > Developer settings
- Use token as password when prompted
Authentication Troubleshooting
OAuth Sign-In Fails
OAuth Sign-In Fails
If OAuth authentication doesn’t work:Check:
- Browser opens to GitHub?
- Firewalls blocking redirect?
- Correct server URL for Enterprise?
- Try signing out and back in
Authentication Fails After Working
Authentication Fails After Working
If authentication stops working:Reasons:
- Token expired
- Token revoked on GitHub
- Password changed
- 2FA enabled/disabled
- Sign out of GitHub Desktop
- Sign back in
- Re-authorize OAuth
SSH Key Not Working
SSH Key Not Working
If SSH authentication fails:Check:Common Issues:
- SSH key not added to ssh-agent
- Public key not added to GitHub
- Wrong permissions on
~/.sshdirectory - Firewall blocking port 22
Generic Git Credentials Not Saved
Generic Git Credentials Not Saved
If credentials aren’t remembered:Check:
- “Remember credentials” was checked
- Credential manager is accessible
- Permissions on credential storage
Enterprise Server Not Accessible
Enterprise Server Not Accessible
If Enterprise server sign-in fails:Verify:
- Correct server URL
- Server is reachable from your network
- SSL certificate is valid
- OAuth app is configured on server
- You have an account on the server
Signing Out
Remove Account
1
Open Accounts
File > Options > Accounts
2
Sign Out
Click Sign out next to the account
3
Confirm
Confirm you want to sign out
4
Token Removed
OAuth token is deleted from credential manager
What Happens
When you sign out:- OAuth token is removed
- Can no longer clone private repos
- Can’t push to repositories
- Can’t create pull requests
- Local repositories remain intact
Removing Credentials
- Sign out from Accounts settings
- Manually delete from OS credential manager
- Clear browser data (for OAuth state)
Best Practices
-
Keep Tokens Secret
- Never commit tokens to repositories
- Don’t share tokens with others
- Regenerate if exposed
-
Use HTTPS in Corporate Networks
- HTTPS works through most proxies
- SSH often blocked by firewalls
- Easier to troubleshoot
-
Enable 2FA
- Adds extra security layer
- Required for many organizations
- Works seamlessly with OAuth
-
Review Token Scopes
- Only grant necessary permissions
- Audit tokens periodically
- Revoke unused tokens
-
Separate Work and Personal
- Use different accounts for work/personal
- Sign in to appropriate account per repository
- Consider separate Git email configs
Security Considerations
Token Security
- Storage: Tokens encrypted by OS credential manager
- Transmission: Always sent over HTTPS
- Scope: Limited to requested permissions
- Rotation: Can be revoked and regenerated
SSH Key Security
- Private Key: Keep private, never share
- Passphrase: Use strong passphrase on private key
- Agent: Use ssh-agent to avoid repeated passphrase entry
- Key Type: Use Ed25519 or RSA 4096-bit keys
Revoking Access
Revoke GitHub Desktop access:- Go to GitHub.com > Settings > Applications
- Find “GitHub Desktop” under Authorized OAuth Apps
- Click Revoke