def generate_ssh_key_ruby(type="RSA", bits = 2048, comment = "OpenShift-Key")
key = RHC::Vendor::SSHKey.generate(:type => type,
:bits => bits,
:comment => comment)
ssh_dir = RHC::Config.ssh_dir
priv_key = RHC::Config.ssh_priv_key_file_path
pub_key = RHC::Config.ssh_pub_key_file_path
if File.exists?(priv_key)
say "SSH key already exists: #{priv_key}. Reusing..."
return nil
else
unless File.exists?(ssh_dir)
FileUtils.mkdir_p(ssh_dir)
File.chmod(0700, ssh_dir)
end
File.open(priv_key, 'w') {|f| f.write(key.private_key)}
File.chmod(0600, priv_key)
File.open(pub_key, 'w') {|f| f.write(key.ssh_public_key)}
ssh_add
end
pub_key
end