gcp create firewall with tags

Here’s another way to create a firewall in GCP using network tag as targets. gcloud compute firewall-rules create "firewall-name" \ --description="egress rule to allow port 8000 to destination" \ --priority "1000" \ --direction EGRESS \ --action allow \ --network "your-network" \ --target-tags="your-network-tag" \ --destination-ranges="10.0.0.1/32" \ --rules tcp:8000

May 28, 2020 · 1 min · ulysses

ec2 password authentication

When you stand up an AWS instance, it’s only accessible via SSH key using the default user, typically ec2-user. Add password to ec2-user, then enable password authentication to ‘yes’ in SSH. # Add password to ec2-user sudo passwd ec2-user # edit ssh config vim /etc/ssh/sshd_config # enable password authentication PasswordAuthentication yes # save file and exit Restart SSH service. systemctl restart sshd.service

May 18, 2020 · 1 min · ulysses

gce agent bash

This is a Bash script to restart a service. #!/bin/bash SERVICE=google_osconfig_agent AGENT=google-osconfig-agent if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) > 0 )) then echo "$AGENT service running, everything is fine" else echo "$AGENT is not running" echo "Restarting service" systemctl start $AGENT sleep 5s if (( $(ps -ef | grep -v grep | grep $SERVICE | wc -l) > 0 )) then sleep 2s echo "$AGENT service is now running" fi fi

May 11, 2020 · 1 min · ulysses

gce agent powershell

This is a Powershell script to restart a service if it’s down. $ServiceName = 'GCEAgent' $arrService = Get-Service -Name $ServiceName if ($arrService.Status -ne 'Running') { Start-Service $ServiceName write-host $arrService.status write-host 'Service starting' Start-Sleep -seconds 60 $arrService.Refresh() if ($arrService.Status -eq 'Running') { Write-Host 'GCE Agent Service is now Running' } } else { Write-Host 'GCE Agent Service is Running' }

May 11, 2020 · 1 min · ulysses

aws ec2 describe snapshots

Here’s how to describe snapshots using query with tags. aws ec2 describe-snapshots \ --owner-ids xxxxxxxxxxx \ --profile default \ --region us-east-2 \ --output text \ --query "Snapshots[*].[SnapshotId,Tags[?Key=='Name'].Value[] | [0]]" Result. snap-xxxxxxxxxxxxxxxxx Server1 snap-xxxxxxxxxxxxxxxxx Server2

May 7, 2020 · 1 min · ulysses

linux screen

If you don’t have it installed. yum install screen apt install screen Before you run a process, run screen, and detach. screen # run the command ping yahoo.com # ctrl-a and ctrl-d to detach To reattach, get a list of screen sessions, and attach to it. screen -ls # result is somewhat similar to below 4452.hostname # attach to it screen -dr 4452.hostname To stop, just type exit from the screen terminal.

May 7, 2020 · 1 min · ulysses

php modules

Here are some missing PHP modules on my WordPress install. apt install php-gd php-dom php-mbstring php-imagick php-zip Reboot Apache after the install. systemctl restart apache2

May 7, 2020 · 1 min · ulysses

sssd leave domain

Here’s how to unjoin or leave the domain via SSSD. realm leave domain.com

April 30, 2020 · 1 min · ulysses

aws s3 sync between accounts

Here’s how to sync S3 buckets between 2 different AWS accounts. Assuming buckets are already created. Setup bucket permissions in Account A Setup IAM user with permissions in Account B Setup bucket permissions in Account B Run S3 sync from Account B. Account A bucket permissions. Account and user are from Account B. { "Version": "2012-10-17", "Statement": [ { "Sid": "DelegateS3Access", "Effect": "Allow", "Principal": {"AWS": "arn:aws:iam::222222222222:user/Jane"}, "Action": ["s3:ListBucket","s3:GetObject"], "Resource": [ "arn:aws:s3:::awsexamplesourcebucket/*", "arn:aws:s3:::awsexamplesourcebucket" ] } ] } Create IAM user (Jane) in Account B ...

April 29, 2020 · 1 min · ulysses

aws cli autoscaler update

Here’s the AWS CLI command to set the Auto Scaling Group to a certain number for the minimum, maximum, and desired number of instances. #!/bin/bash # Format: # ./autoscaling.sh 3 # ./autoscaling.sh 0 int=$1 aws autoscaling update-auto-scaling-group \ --auto-scaling-group-name your-auto-scaling-group \ --min-size $int \ --max-size $int \ --desired-capacity $int \ --region us-east-2 Format: ./autoscaling.sh 0 ./autoscaling.sh 3

April 27, 2020 · 1 min · ulysses