code: def _expand_authorized_keys_path(path, user, home):
      '''
      Expand the AuthorizedKeysFile expression. Defined in man sshd_config(5)
      '''
      converted_path = ''
      had_escape = False
      for char in path:
          if had_escape:
              had_escape = False
              if char == '%':
                  converted_path += '%'
              elif char == 'u':
                  converted_path += user
              elif char == 'h':
                  converted_path += home
              else:
                  error = 'AuthorizedKeysFile path: unknown token character "%{0}"'.format(char)
                  raise CommandExecutionError(error)
              continue
          elif char == '%':
              had_escape = True
          else:
              converted_path += char
      if had_escape:
          error = "AuthorizedKeysFile path: Last character can't be escape character"
          raise CommandExecutionError(error)
      return converted_patf _expand_authorized_keys_path(path, user, home):
      '''
      Expand the AuthorizedKeysFile expression. Defined in man sshd_config(5)
      '''
      converted_path = ''
      had_escape = False
      for char in path:
          if had_escape:
              had_escape = False
              if char == '%':
                  converted_path += '%'
              elif char == 'u':
                  converted_path += user
              elif char == 'h':
                  converted_path += home
              else:
                  error = 'AuthorizedKeysFile path: unknown token character "%{0}"'.format(char)
                  raise CommandExecutionError(error)
              continue
          elif char == '%':
              had_escape = True
          else:
              converted_path += char
      if had_escape:
          error = "AuthorizedKeysFile path: Last character can't be escape character"
          raise CommandExecutionError(error)
      return converted_path
docs: Expand the AuthorizedKeysFile expression. Defined in man sshd_config(5)