BackgroundPathogen infections seriously affect host health, and the use of antibiotics increases the risk of the emergence of drug-resistant bacteria and also increases environmental and health safety risks. Probiotics have received much attention for their excellent ability to prevent pathogen infections. Particularly, explaining mechanism of action of probiotics against pathogen infections is important for more efficient and rational use of probiotics and the maintenance of host health.ResultsHere, we describe the impacts of probiotic on host resistance to pathogen infections. Our findings revealed that (I) the protective effect of oral supplementation withB. velezensisagainstAeromonas hydrophilainfection was dependent on gut microbiota, specially the anaerobic indigenous gut microbeCetobacterium; (II)Cetobacteriumwas a sensor of health, especially for fish infected with pathogenic bacteria; (III) the genome resolved the ability ofCetobacterium someraeCS2105-BJ to synthesize vitamin B12de novo, while in vivo and in vitro metabolism assays also showed the ability ofCetobacterium someraeCS2105-BJ to produce vitamin B12; (IV) the addition of vitamin B12significantly altered the gut redox status and the gut microbiome structure and function, and then improved the stability of the gut microbial ecological network, and enhanced the gut barrier tight junctions to prevent the pathogen infection.ConclusionCollectively, this study found that the effect of probiotics in enhancing host resistance to pathogen infections depended on function of B12produced by an anaerobic indigenous gut microbe,Cetobacterium. Furthermore, as a gut microbial regulator, B12exhibited the ability to strengthen the interactions within gut microbiota and gut barrier tight junctions, thereby improving host resistance against pathogen infection.Video AbstractSupplementary InformationThe online version contains supplementary material available at 10.1186/s40168-023-01574-2.