If you lost your Key Pair, did not set a password for emergency access via VNC, or misconfigured the network and cannot connect to your CentOS Linux Virtual Machine (VM), this guide will help you restore access.
You need to perform the following steps to regain SSH access to your CentOS-based VM:
sudo systemctl status sshd or sudo journalctl -xesudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
sudo ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_keysudo systemctl start sshd. You can verify that the SSH server is running: sudo systemctl status sshdsudo vi /etc/sysconfig/selinux and change enforcing to disabled, then save the changes.sudo getenforce