Resolve the 'SSH key already exists' error

Updated at:

This topic addresses frequently asked questions about deploying SSH keys in new scenarios.

What should I do if I fail to add an SSH key and receive the error message "This key has already been added as a user key or a deployment key. Add failed."?

If you receive the error "This key has been added as a user key or deployment key. Failed to add.", this indicates that the key is already in use. An SSH key is a unique identifier on the platform that authorizes code cloning. If a key is already used by a personal account or a code repository, it cannot be added again. Follow these steps to troubleshoot:

  1. Check if the key is already in use as a personal SSH key by another account.

  2. Check if the key is set as a deployment key for a code repository. You can do this as follows:

    高的 (20).png'Available Keys' are deployment keys that the current account has used. 'Enabled Keys' are deployment keys that the current code repository uses.

Note
  • If a deployment key is configured for multiple code repositories, you must remove it from all of them.

  • When an employee leaves, their associated SSH key is purged when their account is closed. If the account is not closed, the key remains in use. To prevent this issue, remove the key or close the account before the employee leaves. Otherwise, you must generate a new SSH key.