• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

ssh

GCP VM Breakglass SSH

August 28, 2023

When you exhausted all efforts trying to login to a VM and there’s no other way to log in to the server, here’s a breakglass method to allow you to log in to a VM via a startup script. Just add the following bash script to the VM startup section. Change the username and password to your liking. Restart the server to trigger the startup script. After reboot, it should give you access to the server. In addition, you will also have sudo access so you can switch as root.

1. Edit the VM.
2. Go to the Startup script section and add the following.

#!/bin/bash
user="johndoe"
pass="password"
if id $user >/dev/null 2>&1; then
    exit
else
    adduser 
    echo $user:$pass | chpasswd
    usermod -aG google-sudoers $user
fi

#!/bin/bash user="johndoe" pass="password" if id $user >/dev/null 2>&1; then exit else adduser echo $user:$pass | chpasswd usermod -aG google-sudoers $user fi

3. Restart the server.
4. Log in as user.
5. Fix the login issue.
6. Remove user.
7. Remove the startup script.

Filed Under: Cloud, Linux Tagged With: breakglass, gcp, ssh, vm

Google SDK SSH Mac Terminal

February 14, 2022

I’m having trouble logging in using Google SDK Compute SSH on a Mac Terminal.

Here’s the fix.

gcloud compute ssh USERNAME@SERVER --zone ZONE --project PROJECTID --internal-ip 2>&1

gcloud compute ssh USERNAME@SERVER --zone ZONE --project PROJECTID --internal-ip 2>&1

There was an issue with a redirect to another shell.

Filed Under: Cloud, Linux Tagged With: compute, gcp, mac, redirect, sdk, ssh, terminal

Git Switch from HTTPS to SSH

January 20, 2022

If you have trouble cloning a github repo using https, you can tell it to switch to SSH instead.

Here’s the command.

git config --global url.ssh://git@github.com/.insteadOf https://github.com/

git config --global url.ssh://git@github.com/.insteadOf https://github.com/

I had to specify reconfigure when I ran terraform init.

terraform init --reconfigure

terraform init --reconfigure

Filed Under: Cloud, Linux Tagged With: clone, git, https, ssh, switch

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 7
  • Go to Next Page »
  • Home
  • About
  • Search

Copyright © 2023