Github account Attached a Server/PC

1. Remove Stored Credentials

If your GitHub account is authenticated via the credential helper, remove the stored credentials:

bashCopyEditgit credential reject https://github.com

or manually delete credentials:

bashCopyEditrm ~/.git-credentials
rm ~/.config/git/credentials

2. Unset Git Config User Details

Check if the GitHub user is set globally:

bashCopyEditgit config --global --list

If you see user.name and user.email linked to GitHub, remove them:

bashCopyEditgit config --global --unset user.name
git config --global --unset user.email

3. Remove SSH Key (if used for authentication)

Check if an SSH key is linked:

bashCopyEditcat ~/.ssh/id_rsa.pub

If this key is added to GitHub and you want to remove it, delete the SSH key:

bashCopyEditrm -rf ~/.ssh/id_rsa ~/.ssh/id_rsa.pub

4. Clear GitHub Token (if used)

If authentication was done via a Personal Access Token (PAT) and stored in an environment variable or a config file, find and remove it:

bashCopyEditunset GITHUB_TOKEN
sed -i '/GITHUB_TOKEN/d' ~/.bashrc ~/.zshrc

5. Check and Remove OAuth or GCM Credentials

If Git Credential Manager (GCM) was used:

bashCopyEditgit credential reject https://github.com

Github Account Added from these steps

1️⃣ Set Up Git (If Not Installed)

Ensure Git is installed on your system:

sudo apt update && sudo apt install git -y

2️⃣ Configure Your GitHub Username and Email

Run the following commands, replacing with your actual GitHub username and email:

git config --global user.name "YourGitHubUsername"
git config --global user.email "your-email@example.com"

To verify:

git config --global --list

Check if an SSH key already exists:

ls -la ~/.ssh

If id_rsa and id_rsa.pub exist, you can use them. Otherwise, generate a new SSH key:

ssh-keygen -t rsa -b 4096 -C "your-email@example.com"
  • Press Enter to save the key in the default location (~/.ssh/id_rsa).

  • Leave the passphrase empty (or set one for security).


4️⃣ Add the SSH Key to GitHub

Copy the SSH key:

cat ~/.ssh/id_rsa.pub
  • Copy the entire output.

  • Go to GitHub → Settings → SSH and GPG Keys (Click Here).

  • Click New SSH Key, paste the key, and save.


5️⃣ Add the SSH Key to Your SSH Agent

Start the SSH agent:

eval "$(ssh-agent -s)"

Add the key:

ssh-add ~/.ssh/id_rsa

6️⃣ Test the SSH Connection

Run:

ssh -T git@github.com

If successful, you'll see:

Hi YourGitHubUsername! You've successfully authenticated, but GitHub does not provide shell access.

Store HTTPS Credentials Permanently (If You Want to Use HTTPS)

If you prefer using HTTPS (https://github.com/...), configure Git to remember your username and password.

Step 1: Enable Credential Storage

Run:

git config --global credential.helper store

This will save your credentials in plain text (less secure).

Step 2: Authenticate Once

Try cloning or pushing:

git clone https://github.com/flipchat-link/flipchat-client.git

When it asks for a username and password, enter:

  • Username: Your GitHub username

  • Password: Your Personal Access Token (PAT) (GitHub no longer allows passwords for HTTPS authentication)

Step 3: Verify

Now, Git will store your credentials in:

~/.git-credentials

To check:

cat ~/.git-credentials

You'll see an entry like:

https://your_username:your_token@github.com

Now, Git will never ask for credentials again.


Option 3: Use Git Credential Manager (More Secure)

If you want a more secure way to store credentials, install Git Credential Manager:

sudo apt install git-credential-manager
git config --global credential.helper manager-core

Then, try pushing or pulling, and GitHub will remember your credentials securely.


Which Option Should You Use?

  • SSH (Option 1) → Best for security & long-term usage

  • HTTPS with store (Option 2) → Quick but less secure

  • Git Credential Manager (Option 3) → Secure & best for HTTPS users