Authentication issues

更新时间:
复制 MD 格式

When you use Git to manage code, you must configure authentication correctly to ensure security and smooth operations. This topic explains how to set up SSH and HTTPS authentication, handle common authentication errors, and manage multiple accounts on the same computer.

Understand and set up SSH and HTTPS repository authentication

The Git command line supports two main authentication methods: SSH and HTTPS. Each method has unique features and is suitable for different scenarios. Understanding the differences helps you choose the best method and avoid permission-related failures. For more information, see How do I set up SSH or HTTPS repository authentication?

  • SSH authentication: Uses public key authentication for high security. This method eliminates the need to enter a password frequently.

  • HTTPS authentication: Uses a username and a token for basic authentication. This method is ideal when you need to manage access permissions with greater flexibility.

Handle HTTPS clone account or password errors

Common issue: When you clone a repository using HTTPS, you might encounter an account or password error. This can occur because your keychain contains old credentials or you have mistakenly used credentials from a different account. On macOS, the keychain might automatically use expired or incorrect credentials.

Solution:

  • Check and update your account and password information.

  • On macOS, check the records in your local keychain. Remove any unused account information to ensure that the correct credentials are used.

For more information, see How do I handle an HTTPS clone account or password error?

Troubleshoot issues with new SSH deployment keys

Problem description: If you try to add a new SSH key as a deployment key, you might receive a message indicating that the key has already been added. This error occurs because the key already exists in the system and cannot be added again.

Solution:

  • Confirm whether another account is using the key as a personal SSH key.

  • Check the list of enabled deployment keys in the current repository for conflicts.

  • When you leave a project or company, remove unnecessary SSH keys or unregister the associated accounts to prevent future operational issues.

For more information, see What do I do if an SSH key already exists when I try to add it?

Configure multiple SSH keys on one computer to manage multiple Apsara Devops accounts

Background: To manage multiple Apsara Devops accounts on the same computer, you must configure a separate SSH key for each account to differentiate them.

Configuration process:

  • Generate multiple SSH keys: For each account, generate a new SSH key pair. Save each key pair to a different file path.

  • Add SSH keys: Log on to each Apsara Devops account and upload the corresponding public key in your personal settings.

  • Edit the SSH configuration file: Modify the ~/.ssh/config file. For each account, define an alias and specify the path to its private key. This allows the command-line tool to use the correct key for each account.

Switch accounts from the command line: You can use the aliases to easily switch between accounts on the command line for operations such as code pushes and pulls.

For more information, see How do I configure multiple SSH keys on the same computer?