The zero-temperature single-particle Green's function of correlated fermion models with moderately large Hilbert-space dimensions can be calculated by means of Krylov-space techniques. The conventional Lanczos approach consists of finding the ground state in a first step, followed by an approximation for the resolvent of the Hamiltonian in a second step. We analyze the character of this approximation and discuss a numerically exact variant of the Lanczos method which is formulated in the time domain. This method is extended to get the nonequilibrium single-particle Green's function defined on the Keldysh-Matsubara contour in the complex time plane. The proposed method will be important as an exact-diagonalization solver in the context of self-consistent or variational cluster-embedding schemes. For the recently developed nonequilibrium cluster-perturbation theory, we discuss the efficient implementation and demonstrate the feasibility of the Krylov-based solver. The dissipation of a strong local magnetic excitation into a non-interacting bath is considered as an example for applications.