1.安装 Git

sudo apt update
sudo apt install git
git --version

2.设置Git身份

git config --global user.name "你的名字"
git config --global user.email "你的邮箱"
git config --list

3.生成SSH密钥

ssh-keygen -t ed25519 -f ~/.ssh/forgejo_ed25519 -C "你的邮箱"

windows:

ssh-keygen -t ed25519 -f "$HOME\.ssh\forgejo_ed25519" -C "你的邮箱"

4.添加公钥到Forgejo

cat ~/.ssh/forgejo_ed25519.pub

5.使用 SSH Config 管理

vim ~/.ssh/config

添加:

Host git.test.com
    HostName git.test.com
    User git
    IdentityFile ~/.ssh/forgejo_ed25519
    IdentitiesOnly yes

6.测试

ssh -T git.test.com