If you get locked out of SSH into your GCE due to script error (or user mistake) here's how to update the SSH key and regain access | PlexGuide.com

If you get locked out of SSH into your GCE due to script error (or user mistake) here's how to update the SSH key and regain access

  • Stop using Chrome! Download the Brave Browser via >>> [Brave.com]
    It's a forked version of Chrome with native ad-blockers and Google's spyware stripped out! Download for Mac, Windows, Android, and Linux!
Welcome to the PlexGuide.com
Serving the Community since 2016!
Register Now

timekills

VIP
Original poster
Staff
Donor
Sep 12, 2018
367
192
If you accidentally lock yourself out of SSH from another PG instance, (i.e.If you accidentally (*cough*) enter "#1 Log Into the Account" for an already existing server or some other way):

You may have to re-authenticate the account FIRST by if #1 isn't complete. If you accidentally selected #1 - then you've already done this, but need to add the new SSH key the script created.

Get new SSH key
  1. Log into/SSH into your original PG server (not the GCE - the one you used to create the GCE.)
  2. cd ~/.ssh
  3. Copy the SSH key for the system you're logging in from:
    1. To log in from the PlesGuide script type cat google_compute_engine.pub and copy the key.
    2. To log in just from the server itself (NOT using PG script) coy the id_rsa.pub key.

Replace old key with new key in Google Cloud Platform
  1. Go to your GCE "Google Cloud Platform Console": https://console.cloud.google.com/?_ga=2.147913586.-473854088.1546545151
  2. Select Compute Engine -> VM Instances (make sure you're logged into Google as the correct user, and you've selected the correct project as well!)
  3. Click the name of your VM you want to create the SSH account on.
  4. Click "Edit" at the top
  5. Scroll down to "SSH Keys"
  6. Click the text that says "Show and Edit" (it will show your old key/s and username/s)
  7. DELETE the old key for "root" by pressing the X to the right
  8. Paste in the text from step 3 in "Get new SSH Key" section.
    1. It should show a new key with the username "root" to the left and the key in the box to the right.
  9. Scroll down and select "Save"

Refresh your GCE IP through PlexGuide
-Your IP was wiped too, so you'll have to refresh it in PG before you can log in.
  1. Log back into/SSH into your original PG server (not the GCE - the one you used to create the GCE.)
  2. Run PlexGuide and go to "PG Cloud: GCE & Virtual Instances" (#7)
  3. Select "Cloud Instance: Google (For PG GCE Edition)" (#1)
  4. Select "Utilize PG GCE - PlexGuide's" (#1)
  5. MAKE NOTE of the listing under #4 - "Set IP Region / Server" (for example "us-east1 [us-east1]"
    1. You'll have to re-select this region in a moment
  6. Select " "Set IP Region / Server" (#4)
  7. Type the region that the GCE is aready deployed to from step 5/5a
  8. You'll get an error "ERROR: (gcloud.compute.addresses.create) Could not fetch resource:" etc - that's okay.
  9. It should go back to the menu but with an IP set in #4 now. :)

SSH into your box
Now select "SSH into the GCE Box" (#6) and you should be back in.
 
Last edited:
  • Like
Reactions: 2 users

Recommend NewsGroups

      Up To a 58% Discount!

Trending