We extend the generalized Langevin equation (GLE) method [L. Stella, C. D. Lorenz, and L. Kantorovich, Phys. Rev. B 89, 134303 (2014)] to model a central classical region connected to two realistic thermal baths at two different temperatures. In such nonequilibrium conditions a heat flow is established, via the central system, in between the two baths. The GLE-2B (GLE two baths) scheme permits us to have a realistic description of both the dissipative central system and its surrounding baths. Following the original GLE approach, the extended Langevin dynamics scheme is modified to take into account two sets of auxiliary degrees of freedom corresponding to the mapping of the vibrational properties of each bath. These auxiliary variables are then used to solve the non-Markovian dissipative dynamics of the central region. The resulting algorithm is used to study a model of a short Al nanowire connected to two baths. The results of the simulations using the GLE-2B approach are compared to the results of other simulations that were carried out using standard thermostatting approaches (based on Markovian Langevin and Nosé-Hoover thermostats). We concentrate on the steady-state regime and study the establishment of a local temperature profile within the system. The conditions for obtaining a flat profile or a temperature gradient are examined in detail, in agreement with earlier studies. The results show that the GLE-2B approach is able to treat, within a single scheme, two widely different thermal transport regimes, i.e., ballistic systems, with no temperature gradient, and diffusive systems with a temperature gradient.