Quantum entanglement is an important resource in quantum information processing tasks, such as quantum cryptography, quantum teleportation, and quantum computation. The main obstacle to faithful and reliable preparation of entangled states is environment-induced decoherence. Dissipative transition of a general quantum state to an entangled steady state provides an effective strategy to protect entanglement from decoherence, where the decoherence converts into an essential resource. In this paper, we put forward a scheme to prepare generalized Bell states based on trapped ions, in which unitary dynamics and spontaneous emission are combined to drive an arbitrary quantum state in the ground-state space to a unique steady state. The scheme is realized by using the renowned S\o{}rensen-M\o{}lmer setting and is therefore compatible with current experimental technology. Moreover, the vibrational degree of freedom is decoupled from the unitary dynamics so that the scheme does not need to cool the collective vibrational mode to its ground state and thus it works for thermally excited states. Besides, our scheme is demonstrated to be insensitive to variations of some parameters with the aid of numerical simulation.