  Let $p$ be an odd prime. We construct a $p$-group $P$ of nilpotency class
two, rank seven and exponent $p$, such that $\mathrm{Aut}(P)$ induces
$N_{\mathrm{GL}(7,p)}(G_2(p)) = Z(\mathrm{GL}(7,p)) G_2(p)$ on the Frattini
quotient $P/\Phi(P)$. The constructed group $P$ is the smallest $p$-group with
these properties, having order $p^{14}$, and when $p = 3$, our construction
gives two nonisomorphic $p$-groups. To show that $P$ satisfies the specified
properties, we study the action of $G_2(q)$ on the octonion algebra over
$\mathbb{F}_q$, for each power $q$ of $p$, and explore the reducibility of the
exterior square of each irreducible seven-dimensional
$\mathbb{F}_q[G_2(q)]$-module.
