Let $x$ be the troops' speed and $y$ be the messenger's speed.
Total messenger travelling time is $1/x$ (as the troops moved 1km forward).
In the troops frame of reference, the messenger first moved backwards with the speed of $y+x$, and then moved forward with the speed of $y-x$ so that in the $1/x$ total time he returned to the initial position.
Let $z$ be the time messenger spent to reach the rear of the column. Obviously, $z = 1/(y+x)$ (as messenger moves with the speed of $y+x$ relative to the column and has to travel $1$ km relative to the column to reach its rear).
From the other side, we have $z \times (y+x) + (1/x - z) \times (y-x) = 0$, from which follows $2zx + y/x - 1 = 2/(y/x+1) + y/x - 1 = 0$.
Note that the total messenger travelling distance is $d = y/x$. From the previous equation we get $2/(d+1) + d - 1 = 0$, $d^2-3 = 0$, and thus $d = \sqrt{3}$.