Sha256: 607a1a841155081a9b45a91fedaef0eee4f4646172e68fa53d6c100dd4ef37fa
Contents?: true
Size: 899 Bytes
Versions: 4
Compression:
Stored size: 899 Bytes
Contents
module Idlc module Deploy module Keypair class << self def generate(outdir) raise ArgumentError, 'Must specify output directory' if outdir.nil? FileUtils.mkdir_p outdir unless File.directory? outdir private_key_file = "#{outdir}/private_key.pem" public_key_file = "#{outdir}/public_key.pem" rsa_key = if File.exist? private_key_file return if File.exist? public_key_file private_key_data = File.read(private_key_file) SSHKey.new(private_key_data) else SSHKey.generate end private_key = rsa_key.private_key public_key = rsa_key.ssh_public_key File.open(private_key_file, 'w') { |file| file.write(private_key) } File.open(public_key_file, 'w') { |file| file.write(public_key) } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems