SSH Connection Error After Disk Replacement on GCE Linux Instance
→ 日本語版を読むOverview
On GCP, after replacing an "additional disk" on a GCE Linux instance, SSH connection became impossible, but access was restored by changing the disk mount settings.
Error Message
The following error appeared:
Cannot connect to VM on port 22. Please ensure that there is a firewall rule allowing TCP ingress traffic (port: 22) from IP range 0.0.0.0/0 to the VM. <details omitted>
Cause
The /etc/fstab file was configured to throw an error if the disk that was replaced no longer existed.
After replacing the disk, the original disk no longer existed, causing an error, which is believed to be why SSH connection became impossible.
As shown in the site below, Azure apparently shows a clear, understandable error (Cannot SSH to Linux VM due to FSTAB errors), whereas GCP displays the error shown above.
Azure CLI を使用して Linux VM にデータ ディスクを追加する - Azure Virtual Machines | Microsoft Learn
Solution
In the /etc/fstab file, add nofail to the entry for the original disk.
Even if SSH connection becomes impossible, you can connect via serial port, rewrite /etc/fstab, and SSH connection will then work again.
Reference
https://inaba-serverdesign.jp/blog/20170210/cloud_disk_mount_fstab_nofail.html