Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 644086

Summary: [ec2]: key.pem returns a "corrupted" private key
Product: [Retired] CloudForms Cloud Engine Reporter: Chris Lalancette <clalance>
Component: aeolus-conductorAssignee: Angus Thomas <athomas>
Status: CLOSED CURRENTRELEASE QA Contact: wes hayutin <whayutin>
Severity: medium Docs Contact:
Priority: low    
Version: 0.3.1CC: akarol, dajohnso, deltacloud-maint, dgao, ssachdev, sseago, whayutin
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-08 13:50:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 642820    
Attachments:
Description Flags
full irb text none

Description Chris Lalancette 2010-10-18 21:31:32 UTC
Description of problem:
When you use the deltacloud-core client to create a key, you do something like:

 client = Deltacloud.new(username, password, provider.url)
 key = client.create_key(:name => "#{self.name}_#{Time.now.to_i}_key")
 puts key.pem

However, the value returned in key.pem is actually not directly useful as a private key.  The problem is that the way the pem is encoded, every line begins with 4 spaces.  If you take that pem as-is, write it to a file, and try to use it as a private key, ssh complains that the key isn't useful.  Sure, we could workaround the problem by doing something like:

key.pem.each do |line|
   puts line.strip
end

However, it seems like *every* client that wants to use the key would have to do this, so it would seem better to fix it in the core.

I think the reason this is happening is that the core uses a cdata helper function to return this data:

  def cdata(&block)
    text = capture_haml(&block)
    text.gsub!("\n", "x\n ")
    "<![CDATA[\n #{text}\n]]>"
  end

And you can see there that every newline is suffixed with a newline-space, so we get the extra spaces at the beginning of every line.

Comment 1 Michal Fojtik 2010-10-19 12:41:34 UTC
Fixed in:

[PATCH core] Fixed PEM key format in Keys

Patch sent to -incubator mailing list.

Comment 2 Chris Lalancette 2010-10-20 20:41:27 UTC
This has been committed upstream, and is now in the packages for QE to test.  Flipping over to ON_QA.

Chris Lalancette

Comment 3 Dave Johnson 2010-11-05 18:42:35 UTC
Created attachment 458198 [details]
full irb text

I need some help verifying this. I tried to recreate the issue but the key is not generating and being new to the project, I am unsure as to why that is. 


irb(main):023:0> client.create_key(:name => "dave_#{Time.now.to_i}_key")
=> nil
irb(main):024:0>

Comment 4 wes hayutin 2011-04-18 19:30:02 UTC
Shveta, see if you can verify this bug. Your focus is deltacloud so this would be interesting to you.

Comment 5 Shveta 2011-07-11 13:37:58 UTC
<clalance> shveta: Or you can just try to download the key and try to ssh into an instance with it.

I am able to download the key of an instance and ssh to it.

Comment 6 Michal Fojtik 2011-07-11 15:47:19 UTC
I can confirm this also I can provide a simple Ruby script to test it.

Comment 7 wes hayutin 2011-08-01 19:55:32 UTC
release pending...

Comment 8 wes hayutin 2011-08-01 19:57:18 UTC
release pending...

Comment 10 wes hayutin 2011-12-08 13:50:17 UTC
perm close

Comment 11 wes hayutin 2011-12-08 13:53:20 UTC
closing out old bugs