How to set-up a Codeberg account#
After registering on Codeberg, there is some additional steps for a better security:
Set-up a SSH Key#
Following Adding an SSH key to your account, create a SSH private key, with a custom path like ~/.ssh/$USERNAME_codeberg.key (replacing $USERNAME by anything) and a comment to remember the purpose of the key:
ssh-keygen -t ed25519 -a 100 -f ~/.ssh/$USERNAME_codeberg.key -C "admin r4.re codeberg"
Then, add the passphrase to ssh-agent to avoid retyping it each time:
eval $(ssh-agent)
ssh-add ~/.ssh/$USERNAME_codeberg.key
On, Codeberg, add the SSH public key, after copying it:
xclip -selection clipboard < ~/.ssh/$USERNAME_codeberg.key.pub
Verify the key (with the Verify button), a script example is provided, something like this command (with $TOKEN replaced by whatever string Codeberg provides):
echo -n '$TOKEN' | ssh-keygen -Y sign -n gitea -f ~/.ssh/$USERNAME_codeberg.key
Then, add these lines to ~/.ssh/config:
Host codeberg.org
User git
IdentityFile ~/.ssh/$USERNAME_codeberg.key
And test it with:
ssh -T git@codeberg.org
The first time, the prompt will ask to confirm the server fingerprint, enter:
SHA256:mIlxA9k46MmM6qdJOdMnAQpzGxF4WIVVL+fj+wZbw0g
Example session:
Set-up a GPG key#
If you don’t have a GPG key, create one with:
gpg --full-generate-key
The answers to this interactive command should be something like:
1 (RSA and RSA (default))
2y (Key is valid for? (0))
and a name and email, comment is optional
Then, we can check the presence of the new key:
gpg --list-secret-keys --keyid-format LONG
The string after sec rsa4096/ is your key ID, we will use it to output the public key:
gpg --armor --export "$KEY_ID" | xclip -selection clipboard
Paste-it on Codeberg.org, then click on Verify button. It should give you a command to paste in a terminal, like:
echo "$TOKEN" | gpg -a --default-key "$ID" --detach-sig
Add | xclip -selection clipboard at the end of the line to copy it and paste it to the website.
Example session: