Search code examples
linuxubuntugoogle-compute-enginerootchown

Can not connect to SSH Server Google Compute Engine After change chown main folder


I can not connected to my server linux ubuntu who at Google Cloud Compute Engine as root.


Solution

  • This is your solution

    1. Go to the VM instances page in Google Cloud Platform console.
    2. Click on the instance for which you want to add a startup script.
    3. Click the Edit button at the top of the page.
    4. Click on ‘Enable connecting to serial ports’
    5. Under Custom metadata, click Add item.
    6. Set 'Key' to 'startup-script' and set 'Value' to this script:
    #! /bin/bash 
    useradd -G sudo USERNAME 
    echo 'USERNAME:PASSWORD' | chpasswd
    
    1. Click Save and then click RESET on the top of the page. You might need to wait for some time for the instance to reboot.
    2. Click on 'Connect to serial port' in the page.
    3. In the new window, you might need to wait a bit and press on Enter of your keyboard once; then, you should see the login prompt. 10.. Login using the USERNAME and PASSWORD you provided.

    From there undo any change that you've done.