This commit is contained in:
2024-04-03 22:04:13 +02:00
parent 7e68609006
commit 0b373d31db
142 changed files with 7334 additions and 0 deletions

61
tools/1password.md Normal file
View File

@ -0,0 +1,61 @@
# 1Password
1Password is a password manager that provides ability to store various passwords, important documents, secure notes and more.
It supports user-friendly Web interface, as well as macOS, Windows, Linux, iOS, and Android applications.
But also it has *command line interface*, so it can be in use for any application and system to store secure information.
**Note:** 1Password is not free to use, but it provides various pricing plans for personal, family, and business usage.
## Installation
To install 1Password on your device, please follow the [installation link](https://1password.com/downloads/).
## 1Password-CLI
With 1Password CLI, you can automate administrative tasks and load secrets straight from your command line and in your scripts.
### CLI Installation
Install 1Password-CLI on macOS, Windows or Linux, by following the [official 1password-cli installation docs](https://developer.1password.com/docs/cli/get-started#install).
**Example on Mac OS**:
```zsh
brew install --cask 1password/tap/1password-cli
```
### Sign In
To sign in to 1Password CLI with the accounts you've added to the 1Password desktop app, navigate to Developer settings in the app and select "Connect with 1Password CLI". You'll need to add new accounts to the app to use them on the command line if this option is enabled. Follow the [official 1password-cli installation docs](https://developer.1password.com/docs/cli/get-started#sign-in).
If you don't want to connect 1Password CLI and the 1Password app, you'll need to add each account to 1Password CLI manually before you can sign in to it.
```zsh
op account add
```
1Password CLI will prompt you to enter your account details.
After you've added your account, you can sign in to it.
```zsh
eval $(op signin)
```
### Basic Usage
Most useful commands:
| op command | Comment |
| ---------------------------------- | -------------------------------------------- |
| `op --help` | Get list of all possible commands and flags |
| `op account get` | Get details about your account |
| `op user list` | Get list of users |
| `op vault list` | Get details for all vaults |
| `op item get <itemName>` | Get details about an item |
### Environment Variables
It is possible to load secrets from 1Password directly to environment variables.
It can be done by using 1Password CLI, which provides options to load secret values either to environment variable directly, or to `.env` file.
For detailed instruction on how to set up process to load secrets from 1passwords, use to [the official documentation]([1Password-CLI](https://developer.1password.com/docs/cli/secrets-environment-variables/#step-1-create-secret-references)).

14
tools/ansible.md Normal file
View File

@ -0,0 +1,14 @@
# Ansible
## Install Ansible on Ubuntu
1. Install PIP
```bash
sudo apt install python3-pip
```
2. Install Ansible
```bash
pip3 install ansible
```
3. Add execution path
```bash
```

3
tools/bitwarden.md Normal file
View File

@ -0,0 +1,3 @@
# Bitwarden
TODO: WIP

2
tools/chocolatey.md Normal file
View File

@ -0,0 +1,2 @@
# Chocolatey

101
tools/datree.md Normal file
View File

@ -0,0 +1,101 @@
# Datree
Datree can be used on the command line to run policies against Kubernetes manifests YAML files or Helm charts. It prevents Kubernetes misconfigurations from reaching production.
As your organization's infrastructure owner, the products stability is your primary concern. Toolchain engineering and architecture gets pushed to the wayside because you must constantly put out fires configured in the development stage.
## Installation
**Windows** (PowerShell)
```powershell
iwr -useb https://get.datree.io/windows_install.ps1 | iex
setx PATH "$env:path;C:\Users\$env:UserName\AppData\Local\datree" -m
```
**Linux** (Bash)
```bash
sudo apt -y install unzip
curl https://get.datree.io | /bin/bash
```
**Usage**
```bash
datree test ~/.datree/k8s-demo.yaml
```
## Policies
"Centralized policy" is the concept of controlling distributed policy execution from a centralized location. This concept enables the policy owner to easily control the rules that are evaluated in each run of Datree without creating operation overhead. The centralized policy can be managed by logging into the dashboard.
To run the Datree CLI against the new policy (instead of the default one), you will need to add the `-p POLICYNAME` to your policy check execution:
```
datree test ~/.datree/k8s-demo.yaml -p POLICYNAME
```
### Helm
A Helm plugin to validate charts against the Datree policy.
> [!attention]
> Only works on Linux
**Installation Linux** (Bash)
```bash
helm plugin install https://github.com/datreeio/helm-datree
### Usage
Trigger datree policy check via the helm CLI
```bash
helm datree test [CHART_DIRECTORY]
```
**Usage**
If you need to pass helm arguments to your template, you will need to add -- before them:
```bash
helm datree test [CHART_DIRECTORY] -- --values values.yaml --set name=prod
```
## Webhooks
### Installation
Install with providing Datree token. The Datree token is optional, and can be entered during the installation procedure as well.
```bash
DATREE_TOKEN=[your-token] bash <(curl https://get.datree.io/admission-webhook)
```
### Ignore a namespace
Add the label "admission.datree/validate=skip" to the configuration of the namespace you would like to ignore:
```bash
kubectl label namespaces default "admission.datree/validate=skip"
```
To delete the label and resume running the datree webhook on the namespace again:
```bash
kubectl label namespaces default "admission.datree/validate-"
```
### Uninstallation
To uninstall the webhook, copy the following command and run it in your terminal:
```bash
bash <(curl https://get.datree.io/admission-webhook-uninstall)
```
To uninstall the helm release, copy the following command and run it in your terminal:
```bash
helm uninstall datree-webhook -n datree
kubectl delete ns datree
```

38
tools/direnv.md Normal file
View File

@ -0,0 +1,38 @@
# Direnv
Direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload [environment variables](linux/environment-variables-in-linux.md) depending on the current directory.
---
## Installation
Install Direnv on Mac OS, Windows or Linux, by following the [official direnv installation docs](https://direnv.net/docs/installation.html).
**Example on Mac OS**:
```zsh
brew install direnv
```
For direnv to work properly it needs to be hooked into the shell. Each shell has its own extension mechanism. Follow the [official direnv hook docs](https://direnv.net/docs/hook.html).
**Example on zsh**:
```zsh
eval "$(direnv hook zsh)"
```
---
## Getting started
Create a new `.envrc` file with your environment variables.
**Example `.envrc` file**:
```zsh
export ENVVAR="test"
export ENVVAR2="test2"
```
Allow the current directory in **direnv**.
```zsh
direnv allow .
```

128
tools/git.md Normal file
View File

@ -0,0 +1,128 @@
# Git
Git is an open source version control system, which supports your development tasks, especially in distributed code projects.
## Installation
### MacOS
On MacOS, Git can be installed by using the [Homebrew](https://brew.sh/) package manager:
```sh
brew install git
```
Or by installing the XCode command line tools. This can be done by executing the following command:
```sh
xcode-select --install
```
### Linux
On Linux, Git can be easily installed on Linux systems with the available package managers.
E.g. for Debian based systems:
```sh
apt install git
```
### Windows
On Windows, Git can be installed by downloading the installer from the [download page of Git](https://git-scm.com/downloads).
Or by using the winget package manager:
```pwsh
winget install git
```
### Others
For more information, see [download page of Git](https://git-scm.com/downloads).
## Configuration
Git can be configured by the CLI using the `git config` command. For first configuration it is necessary to configure at least the parameters `user.name` and `user.email`. This
can be done by the following commands:
```bash
git config --global user.name "MyFancyUser"
```
```bash
git config --global user.email "developer@mydomain.com"
```
## Using Git
The following commands can be helpful for working with `git`.
### Basic commands
| Git Command | Comment |
| --- | --- |
| `git init` | Initialize a directory as git managed repository |
| `git clone <url>` | Clone a remote repository to your local client |
| `git status` | Shows uncommited changes, new files etc. |
| `git add <file>` | Stage an updated / new file to the next commit |
| `git rm <file>` | Remove a file and stage the removal for the next commit |
| `git commit -m "message"` | Commit staged changes under a new commit |
| `git commit` | Will open an editor to write more descriptive commit messages. See [here](https://cbea.ms/git-commit/) for a guide on good commit messages |
| `git log` | Shows a list of commits in the current branch |
| `git log --pretty=oneline` | Shows a list of commits in the current branch in one line |
| `git log --patch` | Shows a list of commits in the current branch with the changes |
| `git reset <commit>` | Reset the current branch to the given commit |
| `git reset --hard <commit>` | Reset the current branch to the given commit and discard all changes |
| `git reset --soft <commit>` | Reset the current branch to the given commit and keep all changes staged |
| `git checkout <branch>` | Switch to another branch |
| `git branch` | Shows a list of existing branches |
| `git branch <branch>` | Creates a new branch (from the currently checked out branch) |
| `git merge <branch>` | Merge changes from `branch` to the currently checked out branch |
| `git push` | Push commited changes to the remote repository |
| `git pull` | Pull current state from the remote repository to your local repo |
### Working with git-flow
Git-flow assists you by combining multiple steps of `git` commands to one `git-flow` command
which will do a workflow of steps. Although `git-flow` makes live easier in some cases,
it makes it also more complex sometimes and you need to execute some steps before or after using
a `git-flow` command as regular `git` command. (See below)
As an example, here is the comparison between the regular `git` commands and the appropriate
`git-flow` command for creating a release.
| git-flow command | git command |
| --------------------------------------------------- | ----------------------------------------------------- |
| `git-flow feature start <feature_name>` | `git checkout -b feature/<feature_name> develop` |
| `git-flow feature finish <feature_name> [--squash]` | `git checkout develop` |
| | `git merge [--squash] --no-ff feature/<feature_name>` |
| | `git branch -d feature/<feature_name>` |
Another `git-flow` cheat sheet can be found [here](https://danielkummer.github.io/git-flow-cheatsheet/).
## Using git-crypt
Having secret or sensitive information in your git repository is never a good choice. But
sometimes it's necessary. Never push unencrypted data to your remote repository.
Git-crypt is a transparent encryption tool that works seamless with your Git repository. All sensitive
information is encrypted before pushed to the remote repository. Once you've unlocked the
repository locally, all data will be decrypted automatically when pulling from the remote
repo. This makes development with encrypted data effortless.
To install git-crypt, you can use your package manager of choice (e.g. `apt`):
```bash
sudo apt install git-crypt
```
To initialize a new repository with git-crypt, you can use `git-crypt init` when located in the
repository directory. An already encrypted git repository can be unlocked by `git-crypt unlock`.
This requires you to have either the repository encryption key in your GPG keychain, or that
your private GPG key has been added to the allowed keys in the repository. For more details,
see the links below.
For more information, check out the official Github repository [here](https://github.com/AGWA/git-crypt).
A tutorial on git-crypt can be found [here](https://thedatabaseme.de/2022/04/13/lets-keep-this-our-secret-transparent-git-encryption-using-git-crypt/).

2
tools/homebrew.md Normal file
View File

@ -0,0 +1,2 @@
# Homebrew

27
tools/iterm2.md Normal file
View File

@ -0,0 +1,27 @@
# iTerm2
## Tabs and Windows
Shortcut | Description
---|---
`[⌘ Command] + [T]` | New Tab
`[⌘ Command] + [⟶ Right]` | Next Tab
`[⌘ Command] + [⟵ Left]` | Previous Tab
`[⌘ Command] + [W]` | Close Window or Tab
`[⇧ Shift] + [⌘ Command] + [⟶ Right]` | Move Tab right
`[⇧ Shift] + [⌘ Command] + [⟵ Left]` | Move Tab left
`[⌘ Command] + [1], [2], ...` | Go to Tab 1,2,...
`[⌘ Command] + [D]` | Split Window Vertically
`[⇧ Shift] + [⌘ Command] + [D]` | Split Window Horizontally
`[⌘ Command] + [↵ Enter]` | Toggle Fullscreen
`[⇧ Shift] + [⌘ Command] + [↵ Enter]` | Maximize
## Cursor and selection
Shortcut | Description
---|---
`[˄ Control] + [B]` | Move back one character
`[˄ Control] + [F]` | Move forward one character
`[˄ Control] + [D]` | Delete current character
`[˄ Control] + [W]` | Delete previous word (in shell)
`[˄ Control] + [A]` | Move to the start of line
`[˄ Control] + [E]` | Move to the end of line

2
tools/nmap.md Normal file
View File

@ -0,0 +1,2 @@
# NMap

26
tools/openssh.md Normal file
View File

@ -0,0 +1,26 @@
# OpenSSH Cheat-Sheet
## Known Hosts
Remove Entry from the Known-Hosts File.
```bash
ssh-keygen -R hostname
```
## Using the SSH Config File
If you are regularly connecting to multiple remote systems over SSH, you can configure your remote servers with the `.ssh/config` file.
**Example:***
```ini
Host dev
HostName dev.your-domain
User xcad
Port 7654
IdentityFile ~/.ssh/targaryen.key
Host *
User root
Compression yes
```
Connect to a host (like *dev* , eg.) with `ssh dev`.

0
tools/openssl.md Normal file
View File

54
tools/packer.md Normal file
View File

@ -0,0 +1,54 @@
# Packer
Create identical machine images for multiple platforms from a single source configuration.
Project Homepage: https://www.packer.io
Documentation: https://developer.hashicorp.com/packer/docs
Plugins: https://developer.hashicorp.com/packer/plugins
## Installation
### macOS
```sh
brew tap hashicorp/tap
brew install hashicorp/tap/packer
```
### Windows
https://developer.hashicorp.com/packer/downloads
### Linux
#### Ubuntu/Debian
```sh
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install packer
```
## Plugins
TODO: WIP
### Proxmox Builder
The [Proxmox](../infra/proxmox.md) Packer builder is able to create virtual machines and store them as new images using [proxmox-clone](https://developer.hashicorp.com/packer/plugins/builders/proxmox/clone), and [proxmox-iso](https://developer.hashicorp.com/packer/plugins/builders/proxmox/iso).
#### Authentication
TODO: WIP
You can also use the [environment variables](../linux/environment-variables-in-linux.md) `PROXMOX_URL`, `PROXMOX_USERNAME`, `PROXMOX_PASSWORD`, and `PROXMOX_TOKEN` to authenticate to [Proxmox](infra/proxmox.md).
#### Template
```hcl
WIP: TODO
```

19
tools/starship.md Normal file
View File

@ -0,0 +1,19 @@
# Starship Prompt
Starship is a minimal, blazing-fast, and infinitely customizable prompt for any shell.
Project Homepage: [Starship: Cross-Shell Prompt](https://starship.rs/)
Documentation: [Configuration | Starship](https://starship.rs/config/)
## Installation
### Linux
1. Install the latest version for your system:
```
curl -sS https://starship.rs/install.sh | sh
```
2. Add the following to the end of `~/.bashrc` or `~/.zshrc`:
```
eval "$(starship init bash)"
# -- or --
eval "$(starship init zsh)"
```

0
tools/tcpdump.md Normal file
View File

60
tools/terraform.md Normal file
View File

@ -0,0 +1,60 @@
# Terraform
Terraform is a free and open-source infrastructure as code automation tool, to provision, change, and version resources on any environment.
Project Homepage: [Terraform by HashiCorp](https://www.terraform.io/)
Documentation: [Documentation | Terraform by HashiCorp](https://www.terraform.io/docs)
TF Registry: [Terraform Registry](https://registry.terraform.io/)
## Format and Validate
COMMAND | DESCRIPTION
---|---
`terraform fmt` | Reformat your configuration in the standard style
`terraform validate` | Check whether the configuration is valid
## Initialize Working Directory
COMMAND | DESCRIPTION
---|---
`terraform init` | Prepare your working directory for other commands
## Plan, Deploy and Cleanup
COMMAND | DESCRIPTION
---|---
`terraform apply --auto-approve` | Create or update infrastructure without confirmation prompt
`terraform destroy --auto-approve` | Destroy previously-created infrastructure without confirmation prompt
`terraform plan -out plan.out` | Output the deployment plan to plan.out
`terraform apply plan.out` | Use the plan.out to deploy infrastructure
`terraform plan -destroy` | Outputs a destroy plan
`terraform apply -target=aws_instance.myinstance` | Only apply/deploy changes to targeted resource
`terraform apply -var myregion=us-east-1` | Pass a variable via CLI while applying a configuration
`terraform apply -lock=true` | Lock the state file so it can't be modified
`terraform apply refresh=false` | Do not reconcile state file with real-world resources
`terraform apply --parallelism=5` | Number of simultaneous resource operations
`terraform refresh` | Reconcile the state in Terraform state file with real-world resources
`terraform providers` | Get informatino about providers used in the current configuration
## Workspaces
COMMAND | DESCRIPTION
---|---
`terraform workspace new myworkspace` | Create a new workspace
`terraform workspace select default` | Change to a workspace
`terraform workspace list` | List all workspaces
## State Manipulation
COMMAND | DESCRIPTION
---|---
`terraform state show aws_instance.myinstance` | Show details stored in the Terraform state file
`terraform state pull > terraform.tfstate` | Output Terraform state to a file
`terraform state mv aws_iam_role.my_ssm_role module.mymodule` | Move a resource tracked via state to different module
`terraform state replace-provider hashicorp/aws registry.custom.com/aws` | Replace an existing provider with another
`terraform state list` | List all resources tracked in the Terraform state file
`terraform state rm aws_instance.myinstance` | Unmanage a resource, delete it from the Terraform state file
## Import and Outputs
COMMAND | DESCRIPTION
---|---
`terraform import resourcetype.myresource <id>` | Import a Resource
`terraform output` | List all outputs
`terraform output <output>` | List a specific output
`terraform output -json` | List all outputs in JSON format
## Terraform Cloud
COMMAND | DESCRIPTION
---|---
`terraform login` | Login to Terraform Cloud with an API token
`terraform logout` | Logout from Terraform Cloud
## Import existing resources

41
tools/vagrant.md Normal file
View File

@ -0,0 +1,41 @@
# Vagrant Cheat-Sheet
## General Management
COMMAND | DESCRIPTION
---|---
`vagrant status` | Outputs status of the vagrant machine
`vagrant global-status` | Outputs status of all vagrant machines
`vagrant global-status --prune` | Same as above, but prunes invalid entries
## Managing VMs
COMMAND | DESCRIPTION
---|---
`vagrant init` | Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
`vagrant up` | Starts vagrant environment (also provisions only on the FIRST vagrant up)
`vagrant halt` | Stops the vagrant machine
`vagrant suspend` | Suspends a virtual machine (remembers state)
`vagrant resume` | Resume a suspended machine (vagrant up works just fine for this as well)
`vagrant ssh` | Sonnects to machine via SSH
`vagrant ssh <BOXNAME>` | If you give your box a name in your Vagrantfile, you can ssh into it with boxname. Works from any directory.
`vagrant destroy` | Stops and deletes all traces of the vagrant machine
`vagrant destroy -f` | Same as above, without confirmation
## Provisioning VMs
COMMAND | DESCRIPTION
---|---
`vagrant provision` | Forces reprovisioning of the vagrant machine
`vagrant provision --debug ` | Use the debug flag to increase the verbosity of the output
`vagrant up --provision \| tee provision.log` | Runs `vagrant up`, forces provisioning and logs all output to a file
## Manage Boxes
COMMAND | DESCRIPTION
---|---
`vagrant box list` | See a list of all installed boxes on your computer
`vagrant box add <BOXNAME> <BOXURL>` | Download a box image to your computer
`vagrant box outdated` | Check for updates vagrant box update
`vagrant box remove <BOXNAME>` | Deletes a box from the machine
`vagrant package` | Packages a running virtualbox env in a reusable box
## Vagrant with WSL2
Vagrant is able to run inside your Windows Subsystem for Linux environment. A tutorial on how to install
and use it with your Windows installed Virtualbox can be found [here](https://thedatabaseme.de/2022/02/20/vagrant-up-running-vagrant-under-wsl2/).

3
tools/vscode.md Normal file
View File

@ -0,0 +1,3 @@
# VSCode (Visual Studio Code)
**VSCode Shortcuts on MacOS ([[vscode-macos-shortcuts]])**

0
tools/wireshark.md Normal file
View File

92
tools/wsl.md Normal file
View File

@ -0,0 +1,92 @@
# WSL Cheat-Sheet
## Backup and Restore WSL
### Listing Running Distros
```powershell
wsl --list --verbose
```
### Starting/Restarting a Distro
```powershell
wsl --distribution DISTRO-NAME
```
### Terminate a Running Distro
```powershell
wsl --t DISTRO-NAME
```
### Terminate All Running Distros and WSL process
```powershell
wsl --shutdown
```
### Backup a WSL Distro
```powershell
wsl --export (distribution) (filename.tar)
```
### Restore a WSL Distro from Backup
```powershell
wsl --import (distribution) (install location) (file location and filename)
```
## Symbolic Links
### Link .ssh folder
```bash
sudo ln -s /mnt/c/Users/lempa/.ssh ~/.ssh
```
### Link .kube folder
```bash
sudo ln -s /mnt/c/Users/lempa/.ssh ~/.ssh
```
## File Permissions
Advanced settings configuration in WSL: [WSL Config Parameters](https://docs.microsoft.com/en-us/windows/wsl/wsl-config)
**Example wsl.conf**
```
[automount]
enabled = true
options = "metadata,uid=1000,gid=1000,umask=077,fmask=11,case=off"
mountFsTab = true
[interop]
enabled = false
appendWindowsPath = false
```
## Networking
### Port Forwarding
**Find IP Address**
```powershell
bash.exe -c "ifconfig eth0 | grep 'inet '"
```
**Add PortForwarding**
```powershell
$port = 8080
$remoteaddr = 0.0.0.0
netsh interface portproxy add v4tov4 listenport=$port connectport=$port connectaddress=$remoteaddr
netsh advfirewall firewall add rule name=$port dir=in action=allow protocol=TCP localport=$port
```
**Delete PortForwarding**
```PowerShell
$port = 8080
netsh interface portproxy delete v4tov4 listenport=$port
netsh advfirewall firewall delete rule name=$port
```
**Show PortForwardings**
```powershell
netsh interface portproxy show v4tov4
```
## Linux desktop in WSL2
With WSL2 it's possible to install and run a Linux desktop environment (XFCE). A tutorial on how
to implement that, can be found [here](https://thedatabaseme.de/2022/05/15/shorty-running-xfce-linux-desktop-on-wsl2/).