Lesstep
Forgejo · Gitea · Codeberg · SSH · Checked November 22, 2026

Forgejo, Gitea and Codeberg SSH: "Permission denied (publickey)"

The server closed the SSH login because no key that your client offered belongs to an account, or because the user name is not the one the server uses for Git. The words are the same in every case, so the message alone does not say which. On Codeberg the user is always git. On your own server, use the user shown in the clone URL on the repository page, and add the public key under SSH / GPG Keys in your settings.

The message, and what it does not tell you

With OpenSSH 10.2 (November 22, 2026), a key file that does not exist (against codeberg.org and code.forgejo.org) and a new key that is on no account (against codeberg.org) end the same way:

git@codeberg.org: Permission denied (publickey).

With the user forgejo instead of git on codeberg.org the line was the same, only the user name before the at sign changed. A Cloudron forum thread about Forgejo 14.0.3 with its built-in SSH server shows the same line, and the fix there was the user name: ssh -T cloudron@HOST -p 29418 worked where git@ did not (public report).

Pull requests in the IDE do not use SSH: Pull Request Inbox for Forgejo and Gitea, a plugin for JetBrains IDEs, keeps one token for Codeberg and one for your own server, each sent only to its own server, and on a 401 says that the server rejected it and shows the server's message.

Find out which case it is

Run the login test with verbose output (replace the host with your server, and add -p PORT if it does not use port 22):

ssh -vT git@codeberg.org

When it works, the same page says the answer begins with "Hi there, ...! You've successfully authenticated with the key named ..., but Forgejo does not provide shell access."

Fix each case

If SSH asks "Are you sure you want to continue connecting" the first time, that is the host key check, not this error: compare it with the fingerprints Codeberg publishes.

Git over HTTPS instead of SSH needs an access token when 2FA is on: "fatal: Authentication failed".

Forgejo and Gitea pull requests in IntelliJ IDEA

Pull Request Inbox for Forgejo and Gitea, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, keeps one token for Codeberg and one for your own server, each in the IDE's password safe and sent only to its own server. Without a token it reads public repositories; for a private one it says that it needs an access token. When the server refuses a token with 401, the plugin says that the server rejected it (expired or deleted, or from another server), shows the server's message, and offers to open its settings, which link to your server's token page. Reading is free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).

Get it on JetBrains Marketplace

Forgejo, Gitea and Codeberg are names of their respective owners; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by the Forgejo project, Codeberg e.V., the Gitea project or JetBrains.

More: Git over HTTPS "fatal: Authentication failed" with 2FA · Git "self-signed certificate" on your own Forgejo or Gitea · 401 "token is required" and the unknown-token messages · "token does not have at least one of required scope(s)" · 404 "The target couldn't be found." and "not found" · Forgejo and Gitea pull request not created (409, 422, 403) · Forgejo and Gitea pull request plugins for IntelliJ IDEA, compared · 日本語