bomonike

github-install.png

This markdown file provides a comprehensive guide to configuring Windows 11 with Git for GitHub SSH and GPG, with clear sections, code blocks, and additional helpful information.

Microsoft does not provide SSH and GPG tools with Windows 11, so this guide is a user-friendly approach to set up GitHub SSH and GPG on Windows 11.

Install Required Software

  1. Install Git for Windows
  2. Install OpenSSH for Windows (if not already included in your Windows version)
  3. Install Gpg4win

Install Git for Windows

Step 1: Download Git

  1. Visit the official Git website at git-scm.com.
  2. Click on the Download button for Windows. The site will automatically detect your operating system and provide the appropriate installer (64-bit or 32-bit).

Step 2: Run the Installer

  1. Once the download is complete, locate the installer file (usually in your Downloads folder) and double-click it to run.
  2. If prompted by User Account Control, click Yes to allow the installer to make changes to your device.

Step 3: Installation Wizard

  1. License Agreement: Read the GNU General Public License and click Next. Installation Location: Choose the default installation location or select a different one, then click Next.
  2. Select Components: Keep the default options unless you need specific features, then click Next.
  3. Start Menu Folder: Accept the default folder for Git in your Start menu by clicking Next.
  4. Choosing a Text Editor: Select your preferred text editor from the dropdown menu (e.g., Vim, Notepad++) and click Next.
  5. Adjusting Path Environment: Choose “Git from the command line and also from 3rd-party software” to ensure Git is accessible from the command prompt and other tools, then click Next.
  6. Follow through the remaining prompts, adjusting settings as necessary (most users can stick with defaults), and finally click Install.

Step 4: Complete Installation

  1. Once installation is complete, you can choose to launch Git Bash immediately by checking the box before clicking Finish.

Step 5: Verify Installation

  1. Open Git Bash or a Command Prompt window.
  2. Type the following command to check that Git was installed correctly:
     git --version
    

    This command should return the installed version of Git.

Additional Notes

The simplest way to install Git using Windows Package Manager (winget) if you prefer command-line installations:

winget install --id Git.Git -e --source winget

After installation, you can use either Git Bash for command-line operations or Git GUI for graphical interactions with your repositories.

Install OpenSSH for Windows

To install SSH on Windows 11, follow these steps:

  1. Open the Windows Settings app by right-clicking the Start button and selecting “Settings”.
  2. Navigate to “Apps” > “Optional features”12.
  3. Click on “View features” or “Add an optional feature”12.
  4. In the search box, type “OpenSSH”12.
  5. Locate and select “OpenSSH Server” by clicking the checkbox next to it12.
  6. Click “Next” and then “Install” to begin the installation process12.
  7. Wait for the installation to complete.
  8. After installation, you need to start and configure the SSH server:
  9. Open the Windows search and type “Services”1.
  10. Find “OpenSSH SSH Server” in the list of services1.
  11. Right-click on it and select “Start” to run the SSH server1.
  12. To make the SSH server start automatically with Windows, right-click on “OpenSSH SSH Server” again, select “Properties”, and change the “Startup type” to “Automatic”1.
  13. Click “OK” to save the changes.
  14. By default, the SSH server should be accessible through the Windows Firewall. However, if you encounter connection issues, you may need to add a firewall rule:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
  1. You can now connect to your Windows 11 machine using an SSH client from another device by using the command:
     ssh username@ip_address
    
  2. Replace “username” with your Windows user account name and “ip_address” with your Windows 11 machine’s IP address3.

  3. Remember to use strong passwords and consider implementing key-based authentication for enhanced security when using SSH.

Install Gpg4win for Windows

Generate and Configure GPG Key

  1. Open Git Bash and generate a new GPG key:

     gpg --full-generate-key
    
  2. Choose RSA and RSA, 4096 bits, and set an expiration date.
  3. Enter your name and email associated with your GitHub account.
  4. List your GPG keys and note the key ID:
     gpg --list-secret-keys --keyid-format LONG
    
  5. Copy the output and store it in a secure location.
  6. Export your GPG public key:
     gpg --armor --export YOUR_KEY_ID
    
  7. Copy the output and add it to your GitHub account under Settings > SSH and GPG keys > New GPG key.
  8. Configure Git to Use GPG
  9. Set your GPG key in Git:
     git config --global user.signingkey YOUR_KEY_ID
    
  10. Enable automatic signing for commits: ```bash
  11. Export your GPG public key:
     gpg --version
     gpg --armor --export YOUR_KEY_ID
    
  12. Copy the output and add it to your GitHub account under Settings > SSH and GPG keys > New GPG key.
  13. Configure Git to Use GPG
  14. Set your GPG key in Git:
     git config --global user.signingkey YOUR_KEY_ID
    
  15. Enable automatic signing for commits:
     git config --global commit.gpgsign true
    

1, Set Up SSH

  1. Generate a new SSH key:
     ssh-keygen -t ed25519 -C "your_email@example.com"
    
  2. Start the ssh-agent:
     eval "$(ssh-agent -s)"
    
  3. Add your SSH key to the ssh-agent:
     ssh-add ~/.ssh/id_ed25519
    
  4. Copy your SSH public key:
    clip < ~/.ssh/id_ed25519.pub
    
  5. Add the SSH key to your GitHub account under Settings > SSH and GPG keys > New SSH key.
  6. Configure Git to Use SSH
  7. Set your GitHub username:
     git config --global user.name "Your Name"
     git config --global user.email "your_email@example.com"
    
  8. Test your SSH connection:
     ssh -T git@github.com
    

    Additional Notes

  9. Ensure you have the latest versions of Git and GitHub CLI
  10. Keep your SSH and GPG keys secure
  11. Regularly update and rotate your keys

Troubleshooting If you encounter issues, verify:

Recommended Tools: