class SSHKey

def parse_ssh_public_key(public_key)

def parse_ssh_public_key(public_key)
  # lines starting with a '#' and empty lines are ignored as comments (as in ssh AuthorizedKeysFile)
  public_key = public_key.gsub(/^#.*$/, '')
  public_key = public_key.strip # leading and trailing whitespaces wiped out
  raise PublicKeyError, "newlines are not permitted between key data" if public_key =~ /\n(?!$)/
  parsed = public_key.split(" ")
  parsed.each_with_index do |el, index|
    return parsed[index..(index+1)] if SSH_TYPES[el]
  end
  raise PublicKeyError, "cannot determine key type"
end