SSH Public Key Management
In GitCode, you can achieve secure code hosting and commit operations through SSH (Secure Shell Protocol) public keys. SSH public keys offer the following advantages:
- Convenient Access: After using SSH public keys, you do not need to enter the password each time, making access to GitCode repositories more efficient.
- Access Control: You can associate SSH public keys with specific repositories to flexibly manage project access permissions.
- SSH public keys are used in pairs with private keys; please keep your private key safe and avoid disclosure.
- If you use GitCode on multiple devices, it is recommended to generate independent SSH key pairs for each device.
Types of SSH Keys
GitCode supports the following two types of SSH keys:
ED25519 SSH Key
- Higher Security: According to Practical Cryptography With Go, ED25519 keys are more secure than RSA keys.
- Wide Support: Since OpenSSH 6.5 introduced ED25519 in 2014, all major operating systems have supported this key type.
RSA SSH Key
- Key Length Recommendation: If using RSA keys, it is recommended that the key length be 4096 bits (at least 2048 bits) to ensure security.
- Compatibility: By default, the
ssh-keygencommand generates RSA keys with a length of 1024 bits; it is recommended to upgrade to a higher strength. - Security Reminder: Before OpenSSH 7.8, RSA keys' default fingerprints were based on MD5, posing security risks. If you are still using old RSA keys, it is recommended to upgrade to a more secure encryption format.
Generating SSH Keys
Generating ED25519 SSH Key
-
Open Terminal
- On Linux/macOS, open the system terminal.
- On Windows, you can use Cmd, PowerShell, or Git Bash.
-
Enter the command to generate the key
Run the following command, replacing
your_email@example.comwith your email address:ssh-keygen -t ed25519 -C "your_email@example.com"-t ed25519: Specifies the key type as ED25519.-C "your_email@example.com": Adds a comment, typically using your email address for easy identification of the key.
-
Choose the key save location
After running the command, you will see the following prompt:
Generating public/private ed25519 key pair.
Enter file in which to save the key (/Users/user/.ssh/id_ed25519):- Press Enter to accept the default location (
~/.ssh/id_ed25519). - If you need to customize the save path, input a new path, e.g.,
~/.ssh/my_custom_key.
- Press Enter to accept the default location (
-
Set a key password (optional but recommended)
Next, the system will prompt you to set a password:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:- Input a secure password to protect your private key (it is recommended to use a strong password).
- If no password is needed, press Enter to skip.
提示Setting a password means you will need to enter it every time you use the SSH key, preventing unauthorized use of the private key.
-
Confirm successful key generation
If the operation is successful, you will see output similar to the following:
Your identification has been saved in /Users/user/.ssh/id_ed25519
Your public key has been saved in /Users/user/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:x8gFyNRIg5UsIhqYOnsDYhyxXJNhwBU2WcLs11b421g your_email@example.com
The key's randomart image is:
+--[ED25519 256]--+
|o+*@*O==o |
|*o*=* *o.o |
|+=o. .. o . |
|*o . . + = E |
|o+ . . S B |
|. o + . |
| . . |
| |
| |
+----[SHA256]-----+ -
View the generated key
You can view the content of the generated public key with the following command:
cat ~/.ssh/id_ed25519.pubYou will get output similar to the following:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx8z8z8z8z8z8z8z8z8z8z8z8z8z8z8z8z8z8z8z your_email@example.comCopy this public key content for later addition to GitCode.

Generating RSA SSH Key
RSA is a widely supported SSH key type suitable for most scenarios. To ensure security, it is recommended to use a key length of 4096 bits (at least 2048 bits).
-
Enter the command to generate the key
Run the following command, replacing
your_email@example.comwith your email address:ssh-keygen -t rsa -b 4096 -C "your_email@example.com"-
-t rsa: Specifies the key type as RSA. -
-b 4096: Specifies the key length as 4096 bits (recommended). -
-C "your_email@example.com": Adds a comment, typically using your email address for easy identification of the key.
-
-
Choose the key save location
After running the command, you will see the following prompt:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):-
Press Enter to accept the default location (
~/.ssh/id_rsa). -
If you need to customize the save path, input a new path, e.g.,
~/.ssh/my_custom_key.
-
-
Set a key password (optional but recommended)
Next, the system will prompt you to set a password:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:-
Input a secure password to protect your private key (it is recommended to use a strong password).
-
If no password is needed, press Enter to skip.
Password's PurposeSetting a password means you will need to enter it every time you use the SSH key, preventing unauthorized use of the private key.
-
-
Confirm successful key generation
If the operation is successful, you will see output similar to the following:
Your identification has been saved in /Users/.ssh/id_rsa
Your public key has been saved in /Users/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:Ub+LOdZzqYTdq5t+mDAErdkTtzUbnB8VPXJs/cTBDPA your_email@example.com
The key's randomart image is:
+---[RSA 4096]----+
| ....o==B|
| ..o.o.*O=|
| .= o.E+*+|
| o.+ ... o|
| S. .. |
| o* o . |
| *o*o+ |
| . oo=.. |
| .*+. |
+----[SHA256]-----+-
Private Key:
~/.ssh/id_rsa(do not disclose). -
Public Key:
~/.ssh/id_rsa.pub(can be uploaded to GitCode).
-
-
View the generated key
You can view the content of the generated public key with the following command:
cat ~/.ssh/id_rsa.pubOutput example:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArV1... your_email@example.comCopy this public key content for later addition to GitCode.
RSA Keys for OpenSSH 6.5 ~ 7.8
Before OpenSSH 7.8, RSA keys' default fingerprints were based on MD5, posing security risks. If you are using OpenSSH 6.5 to 7.8, it is recommended to take the following measures:
-
Upgrade existing RSA keys
If you already have RSA keys, you can upgrade them to a more secure OpenSSH format with the following command:
ssh-keygen -o -f ~/.ssh/id_rsa -
Generate new RSA keys
If you need to generate new RSA keys, use the following command:
ssh-keygen -o -t rsa -b 4096 -C "your_email@example.com"-o: Saves the private key in a more secure OpenSSH format.
Adding SSH Public Key to GitCode
Now, you can copy your created SSH key to your GitCode account. Taking ED25519 SSH key as an example, you can follow these steps:
-
Copy the SSH public key content
Copy the public key from the file where you saved the SSH key. The following command can save the ED25519 information to the clipboard of the specified operating system:
macOS
pbcopy < ~/.ssh/id_ed25519.pubLinux (requires the xclip package)
xclip -sel clip < ~/.ssh/id_ed25519.pubGit Bash on Windows
cat ~/.ssh/id_ed25519.pub | clip