GitHub Topics (7)Tap to view
    GitHub·Version Control·Topic 1 of 7

    GitHub Authentication & SSH

    Test SSH connectivity with GitHub, switch repository protocol between HTTPS and SSH, and log in via the GitHub CLI.

    1. Authentication and SSH Configuration

    1. ssh -T git@github.com

      What it doesTests the connection from your local SSH key to GitHub and confirms that your account is recognized

      When to use itAfter generating or adding a new SSH key in GitHub settings

      Examplessh -T git@github.com

    2. git remote set-url origin <url>

      What it doesChange the registered remote address (eg switching from HTTPS to SSH)

      When to use itto switch to SSH authentication and avoid the Personal Access Token request

      Examplegit remote set-url origin git@github.com:OWNER/REPO.git

    3. git remote add origin <url>

      What it doesLinks the local repository to a new remote repository on GitHub

      When to use itWhen a new local repository is uploaded for the first time

      Examplegit remote add origin git@github.com:OWNER/REPO.git

    4. gh auth login

      What it doesStarts an interactive wizard to log in to your GitHub account via browser or token

      When to use itWhen setting up the GitHub CLI for the first time on your machine

      Examplegh auth login

    5. gh auth status

      What it doesDisplays the login status, username, and protocol used in the GitHub CLI

      When to use itto check the validity of the session and currently active account

      Examplegh auth status

    6. gh auth refresh -s <scope>

      What it doesUpdate session permissions to add new scopes (such as workflow or write:packages permissions)

      When to use itWhen an order is rejected due to a lack of token permissions

      Examplegh auth refresh -s workflow

    Offline · Reading cached copy