I have heard that for a locally ringed space $X$ whose topology is second countable and Hausdorff, $X$ is a smooth manifold if and only if it is locally ringed space which is locally isomorphic to the sheaf of differentiable functions of some open sets in $\mathbb{R}^n$.

Question: What about the maps between smooth manifolds? Let $M, N$ smooth manifolds and $\phi: M \rightarrow N$ be a continuous map. Does every locally ringed space morphism $\mathcal{O}_N \rightarrow \phi_* \mathcal{O}_M$ come from $\phi$?

I'm asking this because I thought it was true - so that I agree that locally ringed spaces are useful generalizations of (whatever) manifolds - until I tried to prove it tonight. In the process it seems to me that this is NOT true. But if this is not true, why is locally ringed space a good generalization of manifolds if the maps don't behave well? (As opposed to rings $A \rightarrow B$ and spectrum maps $SpecB \rightarrow SpecA$?)

Thanks!