Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bohwaz opened this issue Jul 17, 2019 · 3 comments · Fixed by #7522
Closed

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

bohwaz opened this issue Jul 17, 2019 · 3 comments · Fixed by #7522
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail

Comments

@bohwaz
Copy link

bohwaz commented 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.

@silverwind
Copy link
Member

silverwind commented 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.

@lunny lunny added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Jul 18, 2019
@bohwaz
Copy link
Author

bohwaz commented 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 :)

silverwind added a commit to silverwind/gitea that referenced this issue Jul 22, 2019
lafriks pushed a commit that referenced this issue Jul 23, 2019
* Strip newlines from SSH keys before adding them

Fixes: #7500

* add test for CheckPublicKeyString

* add one more test

* simplify test

* further simplify

* make fmt
@bohwaz
Copy link
Author

bohwaz commented Aug 7, 2019

Great, thank you :)

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants