Accurate channel state information (CSI) is crucial for effective beamforming in wireless communication systems. Unfortunately, the estimation of CSI might not be accurate due to pilot contamination, which happens when the transmission of pilots from the users to access points (APs) is interfered. In systems with a large number of users, non-orthogonal pilot training can increase pilot contamination resulting in incorrect CSI estimation. To address this issue, we propose a pilot-partitioning protocol for distributed massive multiple-input multiple-output (MIMO) systems. The protocol decomposes long-length orthogonal pilots into short-length sub-pilots, transmits them in consecutive slots, and uses the channel correlation among consecutive slots to regenerate orthogonal pilots. In addition, we consider the impact of adversarial transmissions, such as jamming attacks, on CSI estimation. To protect the system against jamming attacks, we propose an AP selection framework to eliminate ineffective APs where the estimated CSI is strongly distorted by jammers. Furthermore, we develop power control strategies for achieving the net throughput maximization and user fairness. Our numerical results show that the proposed designs improve system performance by up to 6.47 times compared to non-optimized scenarios.