How to find all integers $a,b > 1$ satisfying $b \mid a^2+1$ and $a^2 \mid b^3+1$?

Suppose $(a, b)$ is a solution with $a, b \in \mathbb{Z}, a, b>1$. If $b=a^2+1$, then $a^2 \mid (b^3+1)=(a^2+1)^3+1$ so $a^2 \mid 2$, so $a=1$, a contradiction. Thus $\frac{a^2+1}{b}$ is a positive integer $>1$. Note that $a^2 \mid (\frac{a^2+1}{b})^3(b^3+1)=(a^2+1)^3+(\frac{a^2+1}{b})^3$, so $a^2 \mid 1+(\frac{a^2+1}{b})^3$, so if $(a, b)$ is a solution, so is $(a, \frac{a^2+1}{b})$. Note that at least $1$ of $b, \frac{a^2+1}{b}$ is $\leq a$. (Otherwise $a^2+1=b(\frac{a^2+1}{b}) \geq (a+1)^2$, which is impossible) It thus suffices to consider the case where $b \leq a$, since any solution with $b>a$ can be mapped to a solution with $b \leq a$ by above.

If $b=a$, then $b\mid a^2+1=b^2+1$, so $b \mid 1$, so $b=1$, a contradiction. Thus $a \geq b+1$. Write $b^3+1=ca^2$, then $b \mid c(a^2+1)=(b^3+1)+c$ so $b \mid c+1$. Thus $c+1 \geq b$. Therefore $b^3+1=ca^2 \geq (b-1)(b+1)^2=b^3+b^2-b-1$ so $0 \geq b^2-b-2=(b-2)(b+1)$, so $b \leq 2$, so $b=2$. Thus $a^2 \mid (2^3+1)=9$, so $a=3$.

Finally, all solutions are given by $(a, b)=(3, 2)$ and $(a, b)=(3, \frac{3^2+1}{2})=(3, 5)$. These solutions are easily checked to work.