How to Login to GitHub from a Linux Machine: A Step-by-Step Guide

Are you setting up your Linux machine to collaborate on GitHub repositories? Follow these simple steps to login to GitHub and start pushing and pulling code with ease.

  1. Install Git: If Git isn't already installed on your Linux machine, you can install it using your package manager. For example, on Ubuntu, you can run:

    sudo apt install git
    
  2. Configure Git: Set up your Git username and email by running the following commands, replacing "Your GitHub Username" and "Your GitHub Email" with your actual GitHub username and email:

    git config --global user.name "Your GitHub Username"
    git config --global user.email "Your GitHub Email"
    
  3. Generate SSH Key: Generate a new SSH key using the following command. Make sure to replace "your_email@example.com" with the email associated with your GitHub account.

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    
  4. Add SSH Key to SSH Agent: Add your SSH key to the SSH agent to manage your SSH keys easily.

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa
    
  5. Copy SSH Key to Clipboard: Install xclip if not already installed and copy your SSH key to the clipboard.

    sudo apt-get install xclip
    xclip -sel clip < ~/.ssh/id_rsa.pub
    
  6. Add SSH Key to GitHub: Go to your GitHub account settings, navigate to "SSH and GPG keys," and click on "New SSH key" or "Add SSH key." Paste your SSH key into the "Key" field and add a descriptive title. Click "Add SSH key" to save.

  7. Test SSH Connection: Ensure your SSH connection to GitHub is successful by running the following command:

    ssh -T git@github.com
    

That's it! You're now ready to collaborate on GitHub repositories from your Linux machine. Happy coding!