- 1 year ago
Git configuration on windows for ssh access to Github
To configure Git on Windows for SSH access to GitHub, you can follow these steps:
Generate SSH Key Pair:
- Open Git Bash or any terminal of your choice.
- Run the following command to generate a new SSH key pair:mathematica
ssh-keygen -t ed25519 -C "your_email@example.com"
- Press Enter to accept the default file location and enter a passphrase (optional).
- This command generates a new SSH key pair consisting of a private key (
id_ed25519
) and a public key (id_ed25519.pub
).
Add SSH Key to GitHub:
- Go to the GitHub website and sign in to your account.
- Click on your profile picture in the top-right corner and select "Settings".
- In the left sidebar, click on "SSH and GPG keys".
- Click on "New SSH key" or "Add SSH key".
- Give the key a suitable title (e.g., "My SSH Key") and paste the contents of the
id_ed25519.pub
file into the "Key" field. - Click "Add SSH key" to save it.
Configure Git to use SSH:
- Open Git Bash or any terminal of your choice.
- Run the following commands to configure Git to use SSH:arduino
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
git config --global core.sshCommand "ssh -i ~/.ssh/id_ed25519"
Now you should be able to use Git with SSH to interact with your GitHub repositories. When you clone a repository, make sure to use the SSH URL (e.g., git@github.com:user/repo.git
) instead of the HTTPS URL.
To test your SSH connection, run the following command in Git Bash or a terminal:
cssssh -T git@github.com
You should see a message that confirms your connection and mentions your username.
Remember to replace "your_email@example.com" with your actual email address and customize other values (such as "Your Name") according to your preferences.
Note: If you already have SSH keys generated, you can use those instead. Just make sure to add the appropriate public key to your GitHub account.