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 |
There was an issue with a redirect to another shell.
cloud engineer
by Ulysses
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.
by Ulysses
Occasionally I was getting this random error when running Terraform.
╷ │ Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found. │ │ Please see https://registry.terraform.io/providers/hashicorp/aws │ for more information about providing credentials. │ │ Error: RequestError: send request failed │ caused by: Post "https://sts.amazonaws.com/": read tcp xx.xx.xx.xx:59422->xx.xx.xx.xx:443: read: connection reset by peer │ │ │ with provider["registry.terraform.io/hashicorp/aws"], │ on main.tf line 10, in provider "aws": │ 10: provider "aws" { |
╷ │ Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found. │ │ Please see https://registry.terraform.io/providers/hashicorp/aws │ for more information about providing credentials. │ │ Error: RequestError: send request failed │ caused by: Post "https://sts.amazonaws.com/": read tcp xx.xx.xx.xx:59422->xx.xx.xx.xx:443: read: connection reset by peer │ │ │ with provider["registry.terraform.io/hashicorp/aws"], │ on main.tf line 10, in provider "aws": │ 10: provider "aws" {
Here’s the fix. Place this in your ~/.bash_profile.
export AWS_SDK_LOAD_CONFIG=1 |
export AWS_SDK_LOAD_CONFIG=1
This forces Terraform to use both config and credentials file.
by Ulysses
Use Saml2Aws CLI as an alternative to SAML to AWS STS Key Conversion.
Install on Mac.
brew install saml2aws saml2aws --version |
brew install saml2aws saml2aws --version
Configure. Provide information.
saml2aws configure |
saml2aws configure
It will create a ~/.saml2aws config file. Set session to 8 hours.
aws_session_duration = 28800 |
aws_session_duration = 28800
Login.
saml2aws login |
saml2aws login
After authentication and/or MFA, your ~/.aws/credentials will be updated.
by Ulysses
Reset uncommitted changes to both files and directories.
git reset --hard |
git reset --hard
Remove untracked files and directories.
git clean -fd |
git clean -fd
by Ulysses
How to add startup and shutdown scripts on GCP Compute Engine.
Startup Script
gcloud compute instances add-metadata servername \ --project project-id \ --zone us-central1-c \ --metadata=startup-script='#! /bin/bash sudo -i echo "Time: $(date)" >> /tmp/date.txt' |
gcloud compute instances add-metadata servername \ --project project-id \ --zone us-central1-c \ --metadata=startup-script='#! /bin/bash sudo -i echo "Time: $(date)" >> /tmp/date.txt'
Shutdown Script
gcloud compute instances add-metadata servername \ --project project-id \ --zone us-central1-c \ --metadata=shutdown-script='#! /bin/bash # Shuts down Apache server /etc/init.d/apache2 stop' |
gcloud compute instances add-metadata servername \ --project project-id \ --zone us-central1-c \ --metadata=shutdown-script='#! /bin/bash # Shuts down Apache server /etc/init.d/apache2 stop'
by Ulysses
Here’s the command to display only the current directory.
export PROMPT_DIRTRIM=1 |
export PROMPT_DIRTRIM=1
Place the command in your ~/.bashrc to make it permanent.
by Ulysses
Every time I log in to Google Cloud, it’s using the Chromium.
Set BROWSER env to Firefox instead.
export BROWSER=/usr/bin/firefox |
export BROWSER=/usr/bin/firefox
Login to GCP. It should open up Firefox browser instead of Chromium.
gcloud auth login |
gcloud auth login
Add it your .bashrc or .bashprofile if you want it to be permanent.
by Ulysses
Here are command lines you can within SFTP.
Login.
sftp username@servername |
sftp username@servername
Commands available from the local client.
lls lcd lmkdir lpwd lumask |
lls lcd lmkdir lpwd lumask
Commands available on remote server.
cd chmod chown exit get help ln ls mkdir put pwd rename rm rmdir version ! |
cd chmod chown exit get help ln ls mkdir put pwd rename rm rmdir version !