The following is exercise 4.1 of Hartshorne's Deformation Theory, used in the proof given there of the sufficiency of the infinitesimal lifting criterion of smoothness:
Let $(A,m)$ be a local $k$-algebra with residue field $k = A/m$. Let $f : A \rightarrow A$ be a $k$-algebra homomorphism inducing an isomorphism $A/m^2 \rightarrow A/m^2$. Show that $f$ is itself an isomorphism.
Certainly there needs to be a finiteness hypothesis, so far I only need $m$ is finitely generated, but I'm willing to even assume Noetherian.
I can show it is surjective: Let $x_1, \dots, x_n$ be generators of $m$, then we get a surjective map $m/m^2 \rightarrow m/m^2$ and so $\langle f(x_1), \dots, f(x_n)\rangle$ generate (by abuse of notation) $m/m^2$ as a $k$-module. Then $$m = m^2 + \langle f(x_1), \dots, f(x_n) \rangle$$ and so by Nakayama's lemma we get that $f$ surjects onto $m$ and hence all of $A$.
Edit: At the request below, I will show that $f : m \rightarrow m$ is surjective implies $f : A \rightarrow A$ is surjective. It suffices to show that for any unit $u \in A$, there exists an element of $A$ which maps onto $u$. Consider $\bar{u} \in A/m = k$. Since $k \rightarrow A \rightarrow A/m$ is an isomorphism, there exists $\lambda' \in A$ that maps onto $\bar{u}$. Then $u = f(\lambda') + b$ for some $b \in m$. Letting $f(a) = b$, we have $f(\lambda' + a) = u$ as required.
For injectivity, we certainly have $\mathrm{ker} f \subset m^2$. But how does one show that it is zero? Perhaps we can use Nakayama again: it suffices to show that $m \cdot \mathrm{ker} f = \mathrm{ker} f$ but I haven't been able to make this work.
I feel all but certain I'm missing something easy.
A surjective endomorphism of a noetherian ring is an automorphism.
Take $f:A\to A$ a surjective endomorphism and the ascending chain of ideals $\ker f\subseteq\ker f^2\subseteq\cdots$. Then there exists $n\ge 1$ such that $\ker f^n=\ker f^{n+1}=\cdots$. Replace $f$ by $f^n$ and assume that $\ker f=\ker f^2$. Now take $a\in\ker f$. Since $f$ is surjective $a=f(b)$ and from $f(a)=0$ we get $f^2(b)=0$, so $b\in\ker f$, that is, $f(b)=0$ and we are done.