Help Center/ CodeArts Repo/ User Guide/ Old Version/ More About Git/ Setting Password-Free Access via HTTPS
Updated on 2023-07-25 GMT+08:00

Setting Password-Free Access via HTTPS

Background

The username and password are required each time you connect to CodeHub using the HTTPS protocol. However, Git can help you implement password-free access with its credential storage. You are advised to install Git 2.5 or a later version so that the function runs properly. The following describes the configuration methods on different OSs:

Prerequisites

  • You have to enter the username and password in CodeHub each time you use the HTTPS protocol to perform operations such as git clone, git fetch, git pull, and git push.

Setting Password-Free Access on Windows

The following table describes how to set password-free access on Windows.

Table 1 Setting password-free access on Windows

Method

Description

Set the HTTPS password on the local computer

  1. Set the Git authentication mode.

    Open the Git client and run git config --global credential.helper store.

  2. Run the Git command to clone or push code for the first time, and enter the username and password as prompted.
  3. Open the .git-credentials file. If the username and password have been stored locally, the following information is displayed:
    https://username:password@***.***.***.com

Setting Password-Free Access on macOS

Install the osxkeychain tool to implement password-free access.

  1. Check whether the tool has been installed.
    git credential -osxkeychain
    # Test for the cred helper
    Usage: git credential -osxkeychain < get|store|erase >

    If the following information is displayed, the tool has not been installed.

    git: 'credential -osxkeychain' is not a git command. See 'git --help'. 
  2. Obtain the installation package.
    git credential -osxkeychain
    # Test for the cred helper
    git: 'credential -osxkeychain' is not a git command. See 'git --help'.
    curl -s -o \
    https://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
    # Download the helper
    chmod u+x git-credential-osxkeychain
    # Fix the permissions on the file so it can be run
  3. Install osxkeychain in the directory where Git is installed.
    sudo mv git-credential-osxkeychain\
    "$(dirname $(which git))/git-credential-osxkeychain"
    # Move the helper to the path where git is installed
    Password:[enter your password]
  4. Use osxkeychain to set Git to the password-free mode.
    git config --global credential.helper osxkeychain
    #Set git to use the osxkeychain credential helper

    The password needs to be entered the first time you perform Git operations. After that, osxkeychain will manage the username and password, and you do not need to enter password subsequently.

Setting Password-Free Access on Linux

Linux provides two password-free access modes:

  • cache:
    • Credentials are cached in memory and cleared after 15 minutes.
      git config --global credential.helper cache
      #Set git to use the credential memory cache
    • Set the expiration time in timeout, in units of seconds.
      git config --global credential.helper 'cache --timeout=3600'
      # Set the cache to timeout after 1 hour (setting is in seconds)
  • store:

    Credentials are stored in a plain-text file (~/.git-credentials by default) in the home directory on the disk. The credentials never expire unless you change the password on the Git server. The content of the git-credentials file is as follows:

    https://username:password@***********.com

    After saving the credentials in the preceding file, run the following command to implement pass-free access:

    git config --global credential.helper store

Troubleshooting

If the message SSL certificate problem: self signed certificate is displayed when you download code using HTTPS, run the following command on the client:

git config --global http.sslVerify false