Skip to content

Instantly share code, notes, and snippets.

apt update
apt install -y jq curl wget
apt install -y zsh
curl -L http://install.ohmyz.sh | sh
@Benoss
Benoss / install_docker_compose.sh
Last active May 16, 2021 06:07
install_docker_compose.sh Install/update docker compose with the latest released tag from github
#!/usr/bin/env bash
# -e exit on non 0 return
set -e
# -u exit on undefined variables
set -u
# -x print command before running
set -x
# bubble up the non 0 on pipes
set -o pipefail
@Benoss
Benoss / 00-usage.md
Created November 9, 2018 02:45
AutoSSH Tunnel Config

Create a new local tunnel user to keep the .ssh/config clean

sudo useradd -g nogroup -s /bin/false -m tunnel
sudo -u tunnel mkdir -p ~tunnel/.ssh  # and copy your private key here
sudo -u tunnel nano ~tunnel/.ssh/config  # add host and key configs here and a myhostsshconf (or other name)
sudo -u tunnel ssh myhostsshconf  # just make sure to add your host to `known_hosts`

Create a new systemd service with the same name than an entry in the .ssh/config (myhostsshconf in this example)

@Benoss
Benoss / client.txt
Last active November 26, 2021 20:54
new_install
sudo apt install git ncdu htop vim cmake default-jdk nodejs build-essential \
apache2-utils \
apt-transport-https ca-certificates curl \
software-properties-common jq pwgen pv unrar gparted \
redis-server mysql-client-5.7 ntp -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
@Benoss
Benoss / deleteall.sql
Created December 12, 2017 00:24
Delete all tables from current schema in postgres
DO $$ DECLARE
r RECORD;
BEGIN
-- if the schema you operate on is not "current", you will want to
-- replace current_schema() in query with 'schematodeletetablesfrom'
-- *and* update the generate 'DROP...' accordingly.
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
END LOOP;
END $$;
@Benoss
Benoss / install_gitlab.sh
Last active May 1, 2018 07:28
Install Gitlab Runner
echo -e "
sudo apt-get update
sudo apt install curl apt-transport-https ca-certificates -y
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install ntp htop ncdu jq docker-ce gitlab-runner -y
sudo service docker start
@Benoss
Benoss / reverse_tunnel.sh
Last active April 30, 2019 23:08
Reverse tunnel local ssh to remote server on ubuntu and maintain it alive with systemd and autossh
# On the remote machine create a user with no bash
sudo useradd -m -s /bin/false ssh_forwarder
# Take control of the user with bash
sudo -Hu ssh_forwarder /bin/bash
cd ~
mkdir .ssh
ssh-keygen
chmod 700 .ssh/
mv .ssh/id_rsa.pub .ssh/authorized_keys
ps aux | grep process_name | grep refined_grep | awk '{print $2}' | xargs kill
#! /bin/sh
# oneliner to get and update the above script
# wget https://gist.githubusercontent.com/Benoss/3a9aa3c8a5a6b1d94537c02319546534/raw/get_startup_gist.sh -O get_startup_gist.sh && chmod +x get_startup_gist.sh && ./get_startup_gist.sh
# Or you can copy the content of this file
wget https://gist.githubusercontent.com/Benoss/3a9aa3c8a5a6b1d94537c02319546534/raw/install_docker_and_nginx_16_04.sh -O install_docker_and_nginx_16_04.sh
chmod +x install_docker_and_nginx_16_04.sh
./install_docker_and_nginx_16_04.sh
#utils:
@Benoss
Benoss / Install cerbot.sh
Last active January 10, 2017 00:02
Letsencrypt install
#!/bin/bash
wget https://dl.eff.org/certbot-auto
chmod a+x ./certbot-auto
./certbot-auto --help
sudo mkdir /var/www/letsencrypt
sudo chown www-data:www-data /var/www/letsencrypt