Optical fibers offer convenient access to a variety of nonlinear phenomena. However, due to their inversion symmetry, second-order nonlinear effects, such as second-harmonic generation (SHG), are challenging to achieve. Here, all-fiber in-core SHG with high beam quality is achieved in a random fiber laser (RFL). The fundamental wave (FW) is generated in the same RFL. The phase-matching condition is mainly achieved through an induced periodic electric field and the gain is enhanced through the passive spatiotemporal gain modulation and the extended fiber. The conversion needs no pretreatment and the average second-harmonic (SH) power reaches up to 10.06 mW, with a corresponding conversion efficiency greater than 0.04%. Moreover, a theoretical model is constructed to explain the mechanism and simulate the evolution of the SH and FW. Our work offers a simple method to generate higher brightness for in-fiber SHs, and may further provide new directions for research on all-fiber χ(2)-based nonlinear fiber optics and RFLs.