We present an accurate and efficient real-space formulation of the Hellmann-Feynman stress tensor for $mathcal{O}(N)$ Kohn-Sham density functional theory (DFT). While applicable at any temperature, the formulation is most efficient at high temperature where the Fermi-Dirac distribution becomes smoother and density matrix becomes correspondingly more localized. We first rewrite the orbital-dependent stress tensor for real-space DFT in terms of the density matrix, thereby making it amenable to $mathcal{O}(N)$ methods. We then describe its evaluation within the $mathcal{O}(N)$ infinite-cell Clenshaw-Curtis Spectral Quadrature (SQ) method, a technique that is applicable to metallic as well as insulating systems, is highly parallelizable, becomes increasingly efficient with increasing temperature, and provides results corresponding to the infinite crystal without the need of Brillouin zone integration. We demonstrate systematic convergence of the resulting formulation with respect to SQ parameters to exact diagonalization results, and show convergence with respect to mesh size to established planewave results. We employ the new formulation to compute the viscosity of hydrogen at a million kelvin from Kohn-Sham quantum molecular dynamics, where we find agreement with previous more approximate orbital-free density functional methods.