Durgesh
Durgesh

Reputation: 169

Unable to connect google compute engine, getting permission denied error

I have accidentally changed permission of the .ssh folder to 600 and now I am not able to log in to the GCP server through SSH as it's giving me permission denied error.

**Connection Failed**
You cannot connect to the VM instance because of an unexpected error. Wait a few moments and then try again.

I tried multiple options like, ssh troubleshooting instance, enabling serial console, ssh private key login.

Thanks you in advance.

Upvotes: 0

Views: 637

Answers (2)

Durgesh
Durgesh

Reputation: 169

Thank you guys for all your support, my problem got solved by follwing below document: Serial Console with local password using a startup script

Upvotes: 0

Maciek
Maciek

Reputation: 3234

One of the simple ways to fix this would be to use a startup script. In this script just execute chmod 700 /path/to/your/.ssh.

The startup scripts are executed with root privileges, so it should be able to fix your problem with .ssh folder permissions.

So, what you need to do:

  1. Set the startup script.
  2. Restart the VM.
  3. Wait a minute or two to make sure the script got executed.
  4. Remove the startup script from the machine. (no need to restart again)

Upvotes: 2

Related Questions