6. Given that $a$, $b$, and $c$ are the lengths of the three sides of a right triangle, and for a natural number $n$ greater than 2, the following holds:
$$
\left(a^{n}+b^{n}+c^{n}\right)^{2}=2\left(a^{2 n}+b^{2 n}+c^{2 n}\right) .
$$

Then $n=$
6. 4 .

Let $x=a^{\frac{n}{2}}, y=b^{\frac{n}{2}}, z=c^{\frac{\pi}{2}}$, then
$$
\begin{aligned}
0= & 2\left(a^{2 n}+b^{2 n}+c^{2 n}\right)-\left(a^{n}+b^{n}+c^{n}\right)^{2} \\
= & 2\left(x^{4}+y^{4}+z^{4}\right)-\left(x^{2}+y^{2}+z^{2}\right)^{2} \\
= & x^{4}+y^{4}+z^{4}-2 x^{2} y^{2}-2 x^{2} z^{2}-2 y^{2} z^{2} \\
= & -(x+y+z)(x+y-z)(y+z-x)(z+x \\
& -y) .
\end{aligned}
$$

Assume $c$ is the hypotenuse, then $z>x, z>y$. It follows that
$$
x+y+z>0, y+z-x>0, z+x-y>0 \text {. }
$$
$\therefore(*)$ is equivalent to $z=x+y$,
which means $\left(\frac{a}{c}\right)^{\frac{n}{2}}+\left(\frac{b}{c}\right)^{\frac{n}{2}}=1$.
On the other hand, $a^{2}+b^{2}=c^{2}$ holds, or $\left(\frac{a}{c}\right)^{2}+\left(\frac{b}{c}\right)^{2}=$ 1.

Since $0<\frac{a}{c}<1,0<\frac{b}{c}<1, y=\left(\frac{a}{c}\right)^{x}+\left(\frac{b}{c}\right)^{x}$ is a monotonically decreasing function, and it takes $y=1$ at only one point $x$, therefore, $\frac{n}{2}=2, n=4$.