GitHub Authentication¶
Authentication in Git is the process of verifying the identity of the user accessing a Git repository. To authenticate, you must provide identification that the Git server can verify.
Authentication Methods¶
Keeping authentication information secure is essential, as anyone with access can interact with your repository. For HTTPS, use strong passwords and enable two-factor authentication (2FA). For SSH, store your private key securely and use a passphrase.
HTTPS Authentication¶
Authenticate using your GitHub username and password. When pushing or pulling changes, Git prompts for credentials. The remote URL includes your username:
SSH Authentication¶
Authenticate using an SSH key pair. SSH keys allow passwordless authentication. Create a public/private key pair and upload the public key to GitHub. The private key remains on your computer.
The remote URL for SSH authentication:
Your private key file must follow standard naming conventions:
- id_dsa
- id_rsa
- id_ecdsa
- id_ed25519
- id_xmss
To use SSH, add your public key to GitHub under SSH and GPG Keys
. For local repositories, set the origin to SSH:
If you have multiple keys, specify which to use:
[Environment]::SetEnvironmentVariable("GIT_SSH_COMMAND", "ssh -i C:\\Users\\userName\\.ssh\\yourspecifickeyfile", "User")
Test SSH connectivity to GitHub: