25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/beaker-hcloud/ssh_data_patches.rb', line 25
def encode_openssh_private_key(private_key, = '')
public_key = private_key.public_key
private_key_data = [
(SecureRandom.random_bytes(4) * 2),
public_key.rfc4253,
encode_string(private_key.ed25519_key.seed + public_key.ed25519_key.to_str),
encode_string(),
].join
unpadded = private_key_data.bytesize % 8
private_key_data << Array(1..(8 - unpadded)).pack('c*') unless unpadded.zero?
[
::SSHData::Encoding::OPENSSH_PRIVATE_KEY_MAGIC,
encode_string('none'),
encode_string('none'),
encode_string(''),
encode_uint32(1),
encode_string(public_key.rfc4253),
encode_string(private_key_data),
].join
end
|