module SSHData

Constants

AlgorithmError
DecodeError
DecryptError
Error
UnsupportedError
VERSION
VerifyError

Public Instance Methods

key_parts(key) click to toggle source

Break down a key in OpenSSH authorized_keys format (see sshd(8) manual page).

key - An OpenSSH formatted public key or certificate, including algo,

base64 encoded key and optional comment.

Returns an Array containing the algorithm String , the raw key or certificate String and the comment String or nil.

# File lib/ssh_data.rb, line 13
def key_parts(key)
  algo, b64, comment = key.strip.split(" ", 3)
  if algo.nil? || b64.nil?
    raise DecodeError, "bad data format"
  end

  raw = begin
    Base64.strict_decode64(b64)
  rescue ArgumentError
    raise DecodeError, "bad data format"
  end

  [algo, raw, comment]
end