About authentication to GitHub
You can securely access your account’s resources by authenticating to GitHub, using different credentials depending on where you authenticate.
About authentication to GitHub
To keep your account secure, you must authenticate before you can access certain resources on GitHub. When you authenticate to GitHub, 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 GitHub in a variety of ways: in the browser, via GitHub Desktop or another desktop application, with the API, or via the command line. Each way of accessing GitHub supports different modes of authentication.
- Username and password with two-factor authentication, or a passkey
- Personal access token
- SSH key
Authenticating in your browser
If you’re a member of an enterprise with managed users, you will authenticate to GitHub in your browser using your IdP. For more information, see «About Enterprise Managed Users» in the GitHub Enterprise Cloud documentation.
If you’re not a member of an enterprise with managed users, you will authenticate using your GitHub.com username and password, or a passkey. You may also use two-factor authentication and SAML single sign-on, which can be required by organization and enterprise owners.
Note: Starting in March 2023 and through the end of 2023, GitHub will gradually begin to require all users who contribute code on GitHub.com to enable one or more forms of two-factor authentication (2FA). If you are in an eligible group, you will receive a notification email when that group is selected for enrollment, marking the beginning of a 45-day 2FA enrollment period, and you will see banners asking you to enroll in 2FA on GitHub.com. If you don’t receive a notification, then you are not part of a group required to enable 2FA, though we strongly recommend it.
For more information about the 2FA enrollment rollout, see this blog post.
Username and password only
You’ll create a password when you create your account on GitHub. We recommend that you use a password manager to generate a random and unique password. For more information, see «Creating a strong password.»
If you have not enabled 2FA, GitHub will ask for additional verification when you first sign in from an unrecognized device, such as a new browser profile, a browser where the cookies have been deleted, or a new computer.
After providing your username and password, you will be asked to provide a verification code that we will send to you via email. If you have the GitHub Mobile application installed, you’ll receive a notification there instead. For more information, see «GitHub Mobile.»
Two-factor authentication (2FA) (recommended)
If you enable 2FA, after you successfully enter your username and password, we’ll also prompt you to provide a code that’s generated by a time-based one time password (TOTP) application on your mobile device or sent as a text message (SMS).
After you configure 2FA, your account enters a check up period for 28 days. You can leave the check up period by successfully performing 2FA within those 28 days. If you don’t perform 2FA in that timespan, you’ll then be asked to perform 2FA inside one of your existing GitHub.com sessions.
If you cannot perform 2FA to pass the 28th day checkup, you will be provided a shortcut that lets you reconfigure your 2FA settings. You must reconfigure your settings before you can access the rest of GitHub. For more information, see «Accessing GitHub using two-factor authentication» and «Configuring two-factor authentication.»
In addition to authentication with a TOTP application or a text message, you can optionally add an alternative method of authentication with GitHub Mobile or a security key using WebAuthn. For more information, see «Configuring two-factor authentication» and «Configuring two-factor authentication.»
Note: If you cannot use any recovery methods, you have permanently lost access to your account. However, you can unlink an email address tied to the locked account. The unlinked email address can then be linked to a new or existing account. For more information, see «Unlinking your email address from a locked account.»
Passkey (opt-in beta)
- You can add a passkey to your account to enable a secure, passwordless login. Passkeys satisfy both password and 2FA requirements, so you can complete your sign in with a single step. For more information, see «About passkeys» and «Managing your passkeys.»
SAML single sign-on
- Before you can access resources owned by an organization or enterprise account that uses SAML single sign-on, you may need to also authenticate through an IdP. For more information, see «About authentication with SAML single sign-on» in the GitHub Enterprise Cloud documentation.
Authenticating with GitHub Desktop
You can authenticate with GitHub Desktop using your browser. For more information, see «Authenticating to GitHub in GitHub Desktop.»
Authenticating with the API
You can authenticate with the API in different ways. For more information, see «Authenticating to the REST API.»
Authenticating to the API with a personal access token
If you want to use the GitHub REST API for personal use, you can create a personal access token. If possible, GitHub recommends that you use a fine-grained personal access token instead of a personal access token (classic). For more information about creating a personal access token, see «Managing your personal access tokens.»
Authenticating to the API with an app
If you want to use the API on behalf of an organization or another user, GitHub recommends that you use a GitHub App. For more information, see «About authentication with a GitHub App.»
You can also create an OAuth token with an OAuth app to access the REST API. However, GitHub recommends that you use a GitHub App instead. GitHub Apps allow more control over the access and permission that the app has.
Authenticating to the API in a GitHub Actions workflow
If you want to use the API in a GitHub Actions workflow, GitHub recommends that you authenticate with the built-in GITHUB_TOKEN instead of creating a token. You can grant permissions to the GITHUB_TOKEN with the permissions key.
Note that GITHUB_TOKEN can only access resources within the repository that contains the workflow. If you need to make changes to resources outside of the workflow repository, you will need to use a personal access token or GitHub App.
Authenticating with the command line
You can access repositories on GitHub 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 GitHub over HTTPS, even if you are behind a firewall or proxy.
If you authenticate with GitHub CLI, you can either authenticate with a personal access token or via the web browser. For more information about authenticating with GitHub CLI, see gh auth login .
If you authenticate without GitHub CLI, you must authenticate with a personal access token. When Git prompts you for your password, enter your personal access token. Alternatively, you can use a credential helper like Git Credential Manager. Password-based authentication for Git has been removed in favor of more secure authentication methods. For more information, see «Managing your personal access tokens.» Every time you use Git to authenticate with GitHub, you’ll be prompted to enter your credentials to authenticate with GitHub, unless you cache them with a credential helper.
You can work with all repositories on GitHub over SSH, although firewalls and proxies might refuse to allow SSH connections.
If you authenticate with GitHub CLI, the CLI will find SSH public keys on your machine and will prompt you to select one for upload. If GitHub 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 account on GitHub.com. Then, you can either authenticate with a personal access token or via the web browser. For more information about authenticating with GitHub CLI, see gh auth login .
If you authenticate without GitHub CLI, you will need to generate an SSH public/private keypair on your local machine and add the public key to your account on GitHub.com. For more information, see «Generating a new SSH key and adding it to the ssh-agent.» Every time you use Git to authenticate with GitHub, you’ll be prompted to enter your SSH key passphrase, unless you’ve stored the key.
Authorizing for SAML single sign-on
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» in the GitHub Enterprise Cloud documentation.
GitHub’s token formats
GitHub issues tokens that begin with a prefix to indicate the token’s type.
| Token type | Prefix | More information |
|---|---|---|
| Personal access token (classic) | ghp_ | «Managing your personal access tokens» |
| Fine-grained personal access token | github_pat_ | «Managing your personal access tokens» |
| OAuth access token | gho_ | «Authorizing OAuth apps» |
| User access token for a GitHub App | ghu_ | «Authenticating with a GitHub App on behalf of a user» |
| Installation access token for a GitHub App | ghs_ | «Authenticating as a GitHub App installation» |
| Refresh token for a GitHub App | ghr_ | «Refreshing user access tokens» |
Help and support
Help us make these docs great!
All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.
Git Login Command
This article will be demonstrating the use of login instructions on the Kali Linux shell to perform push and pull transactions from the console.
Let’s get started with the setting up of Kali Linux on Windows 10. Tap on the downloaded file of Kali Linux at the Microsoft store and a black window will be opened on your screen. If you are utilizing it for the first time, it may ask you to add a new username. We added the name “Kalsoom” as a new user to our Kali Linux system.
After that, it will require setting a new password for a newly created username. So, add a new password and retype it on the black screen when asked. The user will be created successfully and the kali Linux will be installed properly on your end. The console for admin user “Kalsoom” will be generated as shown below.

Make sure to update your Kali Linux first. This is the most elementary step in any smooth installation process. So, the apt-get package is used to update the Kali Linux with the “update” keyword.

Add your newly created user password to continue updating.

Install Git
You need to install Git on your Kali Linux operating system before using any commands on its console. We will be using the very same “apt-get” package of Linux to install it with the ‘install” keyword followed by the tool name “git”. It will start collecting needed information.

While processing, it may require you to affirm your action to install the tool i.e. git. It will show you the amount of space it will use on your Kali Linux along with asking the question “Do you want to continue?”. Tap “y” from the keypad and press Enter to continue its installation.

All the required repositories of git will be started to download and it may require some time.

After all the packages have been downloaded, you will get the below-shown output “Fetched”.

After that, all the downloaded or loaded packages of git will be installed and git will be ready to configure and use in our Kali Linux operating system.

You need to install the git-related repositories required for proper git working on Linux. You need to use the shown below instruction to continue.

Tap “y” to continue installing listed packages.

Configuring your git identity and email account is among the first tasks you should do after adopting Git. Each transaction you do in Git is associated with your name. Execute the shown “config” instructions to configure your global contributor name, email address, and password.
The “user.name”, “user.email” and “user.passwd” options were used in the config command to do so. We have given the name “kalsoom” to our git user. These configurations can be used globally as per the “—global” option used in the command.

You can see a list of configurations for your git on Kali Linux using the shown below git config command with the “—list” option. The newly created user, email, and password will be displayed on your Linux console screen.

Now, you must have a GitHub account on the GitHub platform as we have shown in the image. We have a public project named “New” which will be used to perform pull and push operations from the Kali Linux platform. It contains 2 files right now.

Within Kali Linux, we have to clone the remote “New” repository so that we can make changes to it and commit them as well. Use the clone “URL” from the GitHub project and use it within the “git clone” instruction as shown below. All the files and folders from new will be cloned.

After using the list instruction, we have found that the “new” project has been cloned well.

You need to initialize a new git repository using the “git init” instruction on the console.

You can check out the status of git using the “git status” instruction. It shows that we haven’t made any commit instructions yet.

Let’s create a text file named “new.txt” in our Linux system using the touch instruction. We will be adding this newly made file to a newly made git repository using the “git add” instruction. After using the “git commit” instruction, the update will be reflected.

Now, you need to run the “git push” instruction along with the clone URL of the remote GitHub “New” repository. Here comes the authentication of username and password for the remote repository. Add your remote username and authentication token/password. It will push all your data to the remote repository as the successful command output shows.

On using the “git log” instruction, we have seen the information regarding the first commit.

You can see that the output and commit has been reflected in the remote “New” repository.
Conclusion
We demonstrated the installation and configuration of a git on Kali Linux along with the cloning of a remote repository on it. We also explained how a user can commit and push files and folders from the Git console on Linux to a remote repository using the login credentials.
how to git login in terminal with code examples
G it is a widely-used version control system for software development. It allows multiple developers to work on the same project simultaneously, track changes, and collaborate efficiently. To work with Git, you first need to log in to your Git account through the terminal.
In this article, we’ll go over the steps to log in to your Git account in the terminal.
Step 1: Install Git
Before logging in to your Git account, make sure that Git is installed on your computer. You can check if Git is installed by typing the following command in the terminal:
If Git is not installed, you can download and install it from the official website (https://git-scm.com/downloads).
Step 2: Create a Git account
If you don’t already have a Git account, you need to create one. You can sign up for a free account at https://github.com.
Step 3: Generate SSH keys
Git uses SSH keys to authenticate and secure your connection to the Git server. To generate an SSH key, open the terminal and type the following command:
Make sure to replace "your_email@example.com" with your actual email address. You’ll be prompted to enter a file location for the SSH key. You can accept the default location by hitting Enter.
Next, you’ll be prompted to enter a passphrase. You can either enter a passphrase or leave it blank by hitting Enter.
Step 4: Add your SSH key to your Git account
To add your SSH key to your Git account, follow these steps:
- Open the terminal and type the following command to view the contents of the SSH key:
Copy the output of the above command.
Go to your Git account settings, navigate to the "SSH and GPG keys" section, and click on the "New SSH key" button.
Give your SSH key a descriptive title and paste the contents of the SSH key in the key field.
Click the "Add SSH key" button to save your changes.
Step 5: Log in to your Git account
To log in to your Git account, open the terminal and type the following command:
If you entered a passphrase when generating your SSH key, you’ll be prompted to enter it now. After entering the passphrase, you’ll see a message indicating that you’ve successfully logged in to your Git account.
Conclusion
Logging in to your Git account through the terminal is the first step in using Git for software development. By following the steps outlined in this article, you can log in to your Git account and start using Git to manage your software projects.
In addition to logging in to your Git account, there are several other Git-related tasks that you can perform through the terminal. In this section, we’ll cover a few of the most commonly used Git commands.
Cloning a Repository
The first step in working with a Git repository is to clone it to your local machine. To clone a repository, use the following command:
Replace "username" with your Git username and "repository" with the name of the repository you want to clone.
Adding and Committing Changes
After you've cloned a repository, you can start making changes to it. To track changes in Git, you first need to add the changes to the staging area using the following command:
The "." at the end of the command means that you want to add all changes in the current directory. You can also specify specific files or directories if you only want to add certain changes.
Once you've added the changes to the staging area, you can commit them to the repository using the following command:
Replace "Commit message" with a descriptive message that summarizes the changes you've made.
Pushing Changes to the Remote Repository
After committing your changes, you need to push them to the remote repository to make them available to other collaborators. To push your changes, use the following command:
The "origin" argument specifies the remote repository and the "master" argument specifies the branch that you want to push your changes to.
Fetching and Merging Changes
When you're collaborating with others on a Git repository, you may need to fetch and merge changes that have been made by others. To fetch changes from the remote repository, use the following command:
Once you've fetched the changes, you can merge them into your local repository using the following command:
The "origin/master" argument specifies the remote branch that you want to merge into your local repository.
Branching
Git allows you to work with multiple branches of a repository simultaneously. You can create a new branch using the following command:
Replace "new-branch" with the name of the branch you want to create. To switch to a different branch, use the following command:
Replace "branch-name" with the name of the branch you want to switch to.
Conclusion
In this article, we've covered the basics of using Git through the terminal, including logging in to your Git account, cloning a repository, adding and committing changes, pushing changes to the remote repository, fetching and merging changes, and branching. With this knowledge, you can start using Git to manage your software projects more effectively.
How to Set Git Username and Password in GitBash?
Git is an open-source version control system. Git is software that helps to track updates in any folder. It is a DevOps resource used mostly for source code planning. It’s typically used to promote collaboration between coders who are relying on source code together during software development. Speed, the integrity of data, including support for dispersed, non-linear workflows are among the aims.
A terminal Git environment is handled by Git Bash (Bash, an acronym for Bourne Again Shell). Git Bash replicates a bash terminal on Windows. It allows you to use all git tools or most other typical Unix commands from the command line. If you’re used to Linux and want to preserve your routines, this is a great alternative.
Git is usually bundled as one of the elevated GUI applications in Windows settings. Bash is a popular Linux and Mac OS default shell. On a Windows operating system, Git Bash is a package that installs Bash, some standard bash utilities, and Git. The fundamental version control system primitives may be abstracted and hidden by Git’s GUI. Git Bash is a Microsoft Windows software that functions as an abstraction shell for the Git command-line experience. A shell is a console application that allows you to interact with your operating system by command prompt.
Now let us discuss how to set Git Username and Password in Git Bash
Step 1: After the successful installation of Git on your system, you have to right-click wherever you want to open the Git tab. Click on the Git Bash Here icon. Now here we will see the location of where the program is opened when the window opens.

Git Bash opened on Desktop.
Step 2: In the Git Bash window, type the below command and press enter. This will configure your Username in Git Bash.
Step 3: After that, you will have to configure your email. For that, type
Step 4: To set your password, type the below command as depicted:
Step 5: To save the credentials forever, type the below command as depicted:
This is how you set git username and password in git bash.
To check the inputs, type the below command as depicted: