Commands not to loose

tech 08-12-2023

VSCode

Formatting

Comment out

SSH

SCP file copy

scp -i ifneeded.pem filesource user@server:/c/file/path/here/file.iso

Copy key to remote server

ssh-copy-id username@remote_host /etc/ssh/sshd_config

find PasswordAuthentication. Make sure it’s uncommented and set to no. If you made any changes, restart sshd

macOS

Power/heat

sudo powermetrics --samplers smc |grep -i "CPU die temperature"

Shortcuts

Linux

Create garbage ssl cert for test:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt

Match user group to anothers:

for i in `grep -E "(:|,)pi(:,|$)" /etc/group |cut -f1 -d: ` ; do sudo addgroup newgroup $i ; done

Windows

Setup SSH

Run in Powershell:

# Check if already setup OpenSSH.Client + OpenSSH.Server
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*' 
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -startuptype 'Automatic'

Remote desktop certificate:

Put cert in LocalMachine Personal, not Remote Desktop

wmic /namespace:\\root\cimv2\TerminalServices PATH Win32_TSGeneralSetting Set SSLCertificateSHA1Hash="f5255204b50382b9b8bff55b043ed9d3b3b681c8"

cURL example

curl --request POST --url http://garbo.com/endpoint --header 'content: things' --data '{"json":"query"}

AWS Items

ECS Commands

aws ecr get-login-password --profile something --region us-east-1 | docker login --username AWS --password-stdin 111222333.dkr.ecr.us-east-1.amazonaws.com
aws ecs update-service --cluster clustername --service servicename --force-new-deployment
aws ecs list-tasks --cluster somecluster
aws ecs describe-tasks --cluster somecluster --tasks 83287vh2387trfd382fd
aws ecs execute-command --cluster somecluster --task 23498722sdf --container somecontainer --command "ls -la" --interactive

Secrets Manager

aws secretsmanager get-secret-value --secret-id nameofsecret
aws secretsmanager delete-secret --secret-id nameofsecret --force-delete-without-recovery

S3

This is the scary one:

aws s3 ls | cut -d" " -f 3 | xargs -l{} aws s3 rb s3://{} --force

Copy shit to bucket:

aws s3 cp /tmp/foo/ s3://bucket/ --recursive --exclude "*.zip" --include "*.jpg"

CloudFormation

aws cloudformation delete-stack --profile staging --stack-name stacknamehere --retain-resources StackThatStuck

RDS

Needs customer managed KMS key:

aws rds create-db-snapshot --profile default --region us-east-1 --db-snapshot-identifier mysnapshot --db-instance-identifier clustername
aws rds copy-db-cluster-snapshot --profile default --region us-east-1 --source-db-cluster-snapshot-identifier mysnapshot --target-db-cluster-snapshot-identifier myencsnapshot --kms-key-id arn:kms:thing:123546
aws rds modify-db-snapshot-attribute --profile default --region us-east-1 --db-snapshot-identifier mysnapshot --attribute-name restore --values-to-add acctnumberhere
aws rds copy-db-cluster-snapshot --profile default --region us-east-1 --source-db-cluster-snapshot-identifier arn::mysnapshot --target-db-cluster-snapshot-identifier mydonesnapshot --kms-key-id arn:kms:thing:123546

Azure

az account list-locations --query "[].{DisplayName:displayName, Name:name}" -o table

Docker

docker run -it --rm -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest
docker build -t $1 . --build-arg="something=nothing" --no-cache --progress plain
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' Minecraft

If encountering random trash local:

docker system prune

Test DNS Resolution:

docker run busybox:1.28 nslookup google.com

Postgresql

pg_dump -Fc -v --host=1.1.1.1 --username=admin --dbname=somedatabase -f db.dump

pg_restore -C -d NewDb -h 1.1.1.1 -p 5432 -W -U admin db.dump

Update a cell:

UPDATE <table>
	SET <column> = 'newvalue’,
		<column2> = ‘newvalue’,
    WHERE <row identifier like ID> = number/value;

Delete a row:

DELETE FROM <table>
WHERE <row identifier like ID> = number/value;
Author's photo

Zerosync

A material girl living in a mechanical world

See other articles: