Centos – Can’t SSH into Google Cloud Compute instance using OS Login after `dnf upgrade`

centosgoogle-cloud-platformgoogle-compute-enginesshssh-keys

I have a Google Cloud Platform Compute instance running CentOS 7. It has been working just fine, where I can use it with the web-based SSH interface without any problem. Recently, I switched to "OS Login" and set it up so I can use RSA keys to authenticate for SSH (using my computer's terminal program, rather than using a browser terminal window). This, too, worked well. (For some reason GCP made a second user account on the CentOS system for me to use, but it doesn't really matter to me.)
The other day, I ran sudo dnf upgrade to update the system. The update finished, and I ran sudo shutdown -r now to reboot.

Running uname -a now gives me Linux centos7 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux.

All of a sudden, I can't SSH into the system using OS Login. (Today I turned OS Login off, and the old method does work.) Here's what I was running into:
– The SSH key I was using didn't work ("Permission denied"). I checked to make sure it was the right one and I know that it didn't expire.
– I couldn't use the GCP browser-based SSH mechanism like I did before. (I'm not sure, but that might be because I turned on OS Login.) If I try to use that, I get a message pop-up that says (one after the other):
"Connecting … Transferring SSH keys to the VM."
"Connecting… Establishing connection to SSH server."
"Could not connect, retrying (1/3)…"
"Timed out connecting to the SSH server."
and
"The VM serial console output may provide details to aid in troubleshooting connection problems. See our help document for other possible causes of this issue." (The "(1/3)" part changes to "(2/3)" and then "(3/3)" after a few seconds.)

The help document link doesn't fix the issue. (https://cloud.google.com/compute/docs/ssh-in-browser#couldnotconnecterror)
– I'm not running a custom OS image.
– I know the disk isn't filled up.
– I haven't been doing anything funny with SSH key file permissions.

The instance did seem to respond to the web interface's start/stop controls, so I restarted it, which didn't change anything.

Looking back at the pop-up message, I checked the serial console output. You can see a copy on pastebin: https://pastebin.com/p8yjGazG
The only thing I can see that might be a problem is a message about not being able to release an IPv6 lease, but then I'm not an expert.

Did the dnf upgrade break something? Am I just missing something obvious? (Is a Google employee playing a prank?)
If anyone could offer some insight into this problem, that would be great!

Best Answer

This is a normal behavior of GCP. You can not have both OS-login enabled and metadata-based SSH key at the same time. please review provided document.[1]

[1] https://cloud.google.com/compute/docs/instances/managing-instance-access

Related Topic