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

Need fix while generating metadata for ssh_keys #454

Closed
kgaikwad opened this issue Apr 15, 2019 · 4 comments · Fixed by #455
Closed

Need fix while generating metadata for ssh_keys #454

kgaikwad opened this issue Apr 15, 2019 · 4 comments · Fixed by #455

Comments

@kgaikwad
Copy link
Contributor

kgaikwad commented Apr 15, 2019

Line-557 generates metadata for ssh-keys.
The expect format of each ssh-key is "[USERNAME_1]:ssh-rsa [EXISTING_KEY_VALUE_1] [USERNAME_1]" mentioned in the google document.

Here -> Line-557 adds "[USERNAME_1]:ssh-rsa [EXISTING_KEY_VALUE_1]".
Any specific reason that it is not appending [USERNAME_1] at the end of string? As user can pass comment while creating ssh-key itself but what if user wants to use same key.

Using current code, I am facing error on VM edit from google console -
'Invalid key. Required format: [email protected] or google-ssh {"userName":"[email protected]","expireOn":""}'

@icco
Copy link
Member

icco commented Apr 25, 2019

weird that it fails, but there was no specific reason for leaving the comment out.

@kgaikwad
Copy link
Contributor Author

kgaikwad commented Apr 26, 2019

@icco,
Thank you for your reply. Yes, it creates VM without an error but later on edit from google console gives above error.

@Temikus
Copy link
Member

Temikus commented May 19, 2019

@kgaikwad First of all - apologies for not getting back to you sooner. Don't currently have a lot of free time so this fell off my radar.

I think the issue is that your key is not in an expected format.

Standard pubkey generated by ssh-keygen should look like:

ssh-rsa AAAAVERYLONGKEYBODY== user@host

I've tried stripping the end off, e.g.:

ssh-rsa AAAAVERYLONGKEYBODY==

, and then I could reproduce the issue you were describing.

What command/lib are you using to generate the keys?

@ezr-ondrej
Copy link

@Temikus I believe the user@host is just an optional comment for the key and we should not expect it to be set as it is just a convention, but you can easily have the key left out.

Should we ensure the comment is present, if without it we fail?

Here is a key parser of gitlab: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ssh_public_key.rb#L26 which internally uses net-ssh( https://www.rubydoc.info/gems/net-ssh/2.9.4/Net/SSH/KeyFactory ) as a parser

Could we use this parser in similar fashion, to actually parse and validate the key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants