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

Split ssh public key and comment #29

Closed
grv87 opened this issue Jun 4, 2017 · 3 comments
Closed

Split ssh public key and comment #29

grv87 opened this issue Jun 4, 2017 · 3 comments

Comments

@grv87
Copy link

grv87 commented Jun 4, 2017

Could you add this feature: split ssh public key to key itself and the comment, so they could be processed separately?

@bensie
Copy link
Owner

bensie commented Jun 5, 2017

@grv87 I'd recommend setting the comment to nil before calling ssh_public_key, that way you can get at the SSH public key without the comment.

key = SSHKey.generate(comment: "bensie")
# => #<SSHKey:0x007fc989a3fed0 @passphrase=nil, @comment="bensie", @directives=[], @key_object=#<OpenSSL::PKey::RSA:0x007fc989a3fd40>, @type="rsa">
key.comment = nil
# => nil
key.ssh_public_key
# => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMa72cykdsZ0yyqeS+Spm/0GimN2uJ0AWY46bpEmAo2TKT3bmionSLVE1kqbTrLfeTrXsbrjnhOgFS3A3BshI4/9i4JeQ5OyqJiotG+S5qQhQsSSC8olwIes2/34cV70aPQa7PNdlfAv1H/7pUVrNu4lJU7BI1NevWpmWG7PG9cu9ifRcdCy7O3CMHiB1HnqCZ6SgSLyedopdCpR8x3fhYWxM6ca+LrUANePMbfC7yPUO4G5mSMGUXmFYCDyIlYQXR3KCzBxHN8y4H1WXMxlSdHFw/qjQtX1rqvtk0yOer/H32xInq/LkO7YtrQhqplPIainHxbnSjcJG8KNmb4brV"

@bensie bensie closed this as completed Jun 5, 2017
@grv87
Copy link
Author

grv87 commented Jun 8, 2017

@bensie, I need to parse existing public key. The same way as valid_ssh_public_key?, but to get the key and the comment separately.

I've ended using split(' ')[0..1] and [2] respectively.

@bensie
Copy link
Owner

bensie commented Jun 8, 2017

Yeah then I think the way you're doing it is your best bet.

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

No branches or pull requests

2 participants