<s>[INST] Pythagorean type diophantine equation. 
How to find all solutions to
$$ a^2+b^2+c^2+d^2=e^2+2$$
where all variables $a$ to $e$ are positive integers and $e^2 \equiv 1 \mod 8$

I tried using parameterization similar to pythagoras equation, but no success so far. Any help will be appreciated.
Thanks!
 [/INST] For such equations, you can use the standard approach. 
One approach is to use equations Pell.  For the beginning will talk about a more simple way.
I. Eq.1 
$$a^2+b^2+c^2+d^2=(2q+1)^2+2$$
Solutions have the form:
$$a=x + k$$
$$b=x + p$$
$$c=x + s$$
$$d=x - z+1$$
$$q=x$$
where,
$$x = -1 -z+ (z^2 - k p - k s - p s),\quad z = k+p+s$$
for any $k,p,s$. 
II. Eq.2 
$$a^2+b^2+c^2+d^2=(4q+1)^2+2$$
Solutions have the form:
$$a=2(y + k)$$
$$b=2(y + p)+1$$
$$c=2(y + s)+1$$
$$d=2(y - z)-1$$
$$q=y$$
where,
$$y = -k + 2z + 2(z^2 - k p - k s - p s),\quad z = k+p+s$$ 
for any $k,p,s$.
III. Eq.3 
$$a^2+b^2+c^2+d^2=(8q+1)^2+2$$
Solutions have the form:
$$a=16k^2+4p^2+4s^2+8pk+8ks+4ps+2s+2p-1$$
$$b=16k^2+4p^2+4s^2+8pk+8ks+4ps+4s+4p+8k$$
$$c=16k^2+4p^2+4s^2+8pk+8ks+4ps+4s+6p+4k+1$$
$$d=16k^2+4p^2+4s^2+8pk+8ks+4ps+6s+4p+4k+1$$
$$q=4k^2+p^2+s^2+2pk+2sk+ps+s+p+k$$
$k,p,s$ - integers asked us.
</s>