1
0
mirror of synced 2025-12-21 10:57:10 -05:00
Files
docs/content/github/authenticating-to-github/keeping-your-account-and-data-secure/about-authentication-to-github.md
Sarah Edwards 95bd8c84f9 [Aug 24, 2021] Top level CLI docs set (#20628)
Co-authored-by: Ethan Palm <56270045+ethanpalm@users.noreply.github.com>
Co-authored-by: Mislav Marohnić <mislav@github.com>
Co-authored-by: Laura Coursen <lecoursen@github.com>
2021-08-24 15:44:25 +00:00

8.9 KiB

title, intro, versions, topics, redirect_from, shortTitle
title intro versions topics redirect_from shortTitle
About authentication to GitHub You can securely access your account's resources by authenticating to {% data variables.product.product_name %}, using different credentials depending on where you authenticate.
fpt ghes ghae
* * *
Identity
Access management
/github/authenticating-to-github/about-authentication-to-github
Authentication to GitHub

About authentication to {% data variables.product.prodname_dotcom %}

To keep your account secure, you must authenticate before you can access{% ifversion not ghae %} certain{% endif %} resources on {% data variables.product.product_name %}. When you authenticate to {% data variables.product.product_name %}, you supply or confirm credentials that are unique to you to prove that you are exactly who you declare to be.

You can access your resources in {% data variables.product.product_name %} in a variety of ways: in the browser, via {% data variables.product.prodname_desktop %} or another desktop application, with the API, or via the command line. Each way of accessing {% data variables.product.product_name %} supports different modes of authentication.

  • {% ifversion ghae %}Your identity provider (IdP){% else %}Username and password with two-factor authentication{% endif %}
  • Personal access token
  • SSH key

Authenticating in your browser

You can authenticate to {% data variables.product.product_name %} in your browser {% ifversion ghae %}using your IdP. For more information, see "About authentication with SAML single sign-on."{% else %}in different ways.

  • Username and password only
    • You'll create a password when you create your user account on {% data variables.product.product_name %}. We recommend that you use a password manager to generate a random and unique password. For more information, see "Creating a strong password."
  • Two-factor authentication (2FA) (recommended)

Authenticating with {% data variables.product.prodname_desktop %}

You can authenticate with {% data variables.product.prodname_desktop %} using your browser. For more information, see "Authenticating to {% data variables.product.prodname_dotcom %}."

Authenticating with the API

You can authenticate with the API in different ways.

Authenticating with the command line

You can access repositories on {% data variables.product.product_name %} from the command line in two ways, HTTPS and SSH, and both have a different way of authenticating. The method of authenticating is determined based on whether you choose an HTTPS or SSH remote URL when you clone the repository. For more information about which way to access, see "About remote repositories."

HTTPS

You can work with all repositories on {% data variables.product.product_name %} over HTTPS, even if you are behind a firewall or proxy.

If you authenticate with {% data variables.product.prodname_cli %}, you can either authenticate with a personal access token or via the web browser. For more information about authenticating with {% data variables.product.prodname_cli %}, see gh auth login.

If you authenticate without {% data variables.product.prodname_cli %}, you must authenticate with a personal access token. {% data reusables.user_settings.password-authentication-deprecation %} Every time you use Git to authenticate with {% data variables.product.product_name %}, you'll be prompted to enter your credentials to authenticate with {% data variables.product.product_name %}, unless you cache them a credential helper.

SSH

You can work with all repositories on {% data variables.product.product_name %} over SSH, although firewalls and proxys might refuse to allow SSH connections.

If you authenticate with {% data variables.product.prodname_cli %}, the CLI will find SSH public keys on your machine and will prompt you to select one for upload. If {% data variables.product.prodname_cli %} does not find a SSH public key for upload, it can generate a new SSH public/private keypair and upload the public key to your {% data variables.product.product_name %} account. Then, you can either authenticate with a personal access token or via the web browser. For more information about authenticating with {% data variables.product.prodname_cli %}, see gh auth login.

If you authenticate without {% data variables.product.prodname_cli %}, you will need to generate an SSH public/private keypair on your local machine and add the public key to your {% data variables.product.product_name %} account. For more information, see "Generating a new SSH key and adding it to the ssh-agent." Every time you use Git to authenticate with {% data variables.product.product_name %}, you'll be prompted to enter your SSH key passphrase, unless you've stored the key.

Authorizing for SAML single sign-on

{% ifversion fpt %}To use a personal access token or SSH key to access resources owned by an organization that uses SAML single sign-on, you must also authorize the personal token or SSH key. For more information, see "Authorizing a personal access token for use with SAML single sign-on" or "Authorizing an SSH key for use with SAML single sign-on."{% endif %}

{% ifversion fpt or ghes > 3.1 or ghae-next %}

{% data variables.product.company_short %}'s token formats

{% data variables.product.company_short %} issues tokens that begin with a prefix to indicate the token's type.

Token type Prefix More information
Personal access token ghp_ "Creating a personal access token"
OAuth access token gho_ "Authorizing {% data variables.product.prodname_oauth_apps %}"
User-to-server token for a {% data variables.product.prodname_github_app %} ghu_ "Identifying and authorizing users for {% data variables.product.prodname_github_apps %}"
Server-to-server token for a {% data variables.product.prodname_github_app %} ghs_ "Authenticating with {% data variables.product.prodname_github_apps %}"
Refresh token for a {% data variables.product.prodname_github_app %} ghr_ "Refreshing user-to-server access tokens"

{% endif %}