Adding a deploy key from copy/paste doesn't work #3610

Closed
opened 2025-11-02 05:19:24 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @bohwaz on GitHub (Jul 17, 2019).

  • Gitea version (or commit ref): 1.8.3

Description

If I do a cat ~/.ssh/id_rsa.pub and copy paste it in Gitea to the textarea to add a new deploy key, I get the error "Can not verify your SSH key: extractTypeFromBase64Key: invalid key format: illegal base64 data at input byte 168"

If I remove the line break in the middle, it works.

It seems that Gitea doesn't handle line returns inside keys.

Originally created by @bohwaz on GitHub (Jul 17, 2019). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.8.3 ## Description If I do a `cat ~/.ssh/id_rsa.pub` and copy paste it in Gitea to the textarea to add a new deploy key, I get the error "Can not verify your SSH key: extractTypeFromBase64Key: invalid key format: illegal base64 data at input byte 168" If I remove the line break in the middle, it works. It seems that Gitea doesn't handle line returns inside keys.
GiteaMirror added the issue/needs-feedback label 2025-11-02 05:19:24 -06:00
Author
Owner

@silverwind commented on GitHub (Jul 17, 2019):

SSH Keys have no linebreaks in the middle, it's probably your terminal erronously adding them. Does adding the same faulty key on GitHub work, btw?

It may be possible that we can prevent such errors by stripping any \r?\n sequences from the added key on save because those should never appear in a key afaik.

@silverwind commented on GitHub (Jul 17, 2019): SSH Keys have no linebreaks in the middle, it's probably your terminal erronously adding them. Does adding the same faulty key on GitHub work, btw? It may be possible that we can prevent such errors by stripping any `\r?\n` sequences from the added key on save because those should never appear in a key afaik.
Author
Owner

@bohwaz commented on GitHub (Jul 18, 2019):

SSH Keys have no linebreaks in the middle, it's probably your terminal erronously adding them. Does adding the same faulty key on GitHub work, btw?

Yes it works on github and gitlab.

It may be possible that we can prevent such errors by stripping any \r?\n sequences from the added key on save because those should never appear in a key afaik.

Would be a good solution :)

@bohwaz commented on GitHub (Jul 18, 2019): > SSH Keys have no linebreaks in the middle, it's probably your terminal erronously adding them. Does adding the same faulty key on GitHub work, btw? Yes it works on github and gitlab. > It may be possible that we can prevent such errors by stripping any `\r?\n` sequences from the added key on save because those should never appear in a key afaik. Would be a good solution :)
Author
Owner

@bohwaz commented on GitHub (Aug 7, 2019):

Great, thank you :)

@bohwaz commented on GitHub (Aug 7, 2019): Great, thank you :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3610