Configuring SSH Public Key¶
This article explains how to configure SSH public key.
Step 1. View Existing SSH Keys¶
Before generating a new SSH key, please check if you need to use an existing SSH key stored in the root directory of the local user. For Linux and Mac, use the following command to view existing public keys. Windows users can use the following command in WSL (requires Windows 10 or above) or Git Bash to view the generated public keys.
-
ED25519 Algorithm:
-
RSA Algorithm:
If a long string starting with ssh-ed25519 or ssh-rsa is returned, it means that a local public key already exists. You can skip Step 2 Generate SSH Key and proceed directly to Step 3.
Step 2. Generate SSH Key¶
If Step 1 does not return the specified content string, it means that there is no available SSH key locally and a new SSH key needs to be generated. Please follow these steps:
-
Access the terminal (Windows users please use WSL or Git Bash), and run
ssh-keygen -t
. -
Enter the key algorithm type and an optional comment.
The comment will appear in the .pub file and can generally use the email address as the comment content.
-
To generate a key pair based on the
ED25519
algorithm, use the following command: -
To generate a key pair based on the
RSA
algorithm, use the following command:
-
-
Press Enter to choose the SSH key generation path.
Taking the ED25519 algorithm as an example, the default path is as follows:
Generating public/private ed25519 key pair. Enter file in which to save the key (/home/user/.ssh/id_ed25519):
The default key generation path is
/home/user/.ssh/id_ed25519
, and the corresponding public key is/home/user/.ssh/id_ed25519.pub
. -
Set a passphrase for the key.
The passphrase is empty by default, and you can choose to use a passphrase to protect the private key file. If you do not want to enter a passphrase every time you access the repository using the SSH protocol, you can enter an empty passphrase when creating the key.
-
Press Enter to complete the key pair creation.
Step 3. Copy the Public Key¶
In addition to manually copying the generated public key information printed on the command line, you can use the following commands to copy the public key to the clipboard, depending on the operating system.
Step 4. Set the Public Key on DCE 5.0 Platform¶
-
Log in to the DCE 5.0 UI page and select Profile -> SSH Public Key in the upper right corner of the page.
-
Add the generated SSH public key information.
-
SSH public key content.
-
Public key title: Supports customizing the public key name for management differentiation.
-
Expiration: Set the expiration period for the public key. After it expires, the public key will be automatically invalidated and cannot be used. If not set, it will be permanently valid.
-