I am unable to access my Google Cloud VM via SSH. When I try to connect, I get a "Connection Failed" error stating that SSH on port 22 is not accessible. I have already checked the firewall rules, ensured SSH is allowed, and restarted the SSH service, but the issue persists. The UFW logs show "BLOCK" messages, and the Google guest agent is failing to update SSH keys. I also tried mounting the disk on another VM to manually update the keys, but I still cannot connect. How can I regain SSH access to my VM?
Have you tried to access the Compute engine through serial console?
Thanks,
Darwin Vinoth.
Linkedin
Hi @Jahi,
Welcome to Google Cloud Community!
Here is a basic step-by-step troubleshooting guide on how you can recover SSH access:
sudo ufw disable
sudo systemctl restart ssh
sudo ufw allow OpenSSH
sudo ufw allow 22/tcp
sudo ufw reload
sudo systemctl restart ssh
sudo systemctl status google-guest-agent
sudo systemctl restart google-guest-agent
ssh-keygen -t rsa -b 4096 -f ~/.ssh/gce_key -C "your-email@example.com"
echo "ssh-rsa AAAAB3..." | sudo tee -a /home/YOUR_USERNAME/.ssh/authorized_keys
sudo chmod 600 /home/YOUR_USERNAME/.ssh/authorized_keys
sudo chown YOUR_USERNAME:YOUR_USERNAME /home/YOUR_USERNAME/.ssh/authorized_keys
sudo systemctl restart ssh
ssh -i ~/.ssh/gce_key YOUR_USERNAME@YOUR_VM_IP
sudo journalctl -u ssh --no-pager | tail -n 50
If you need further assistance, you can reach out to Google Cloud Support at any time.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.