Skip to content

Instantly share code, notes, and snippets.

@nicksan2c
nicksan2c / how-to-restore.md
Created October 21, 2021 00:35 — forked from AmazingTurtle/how-to-restore.md
restore access to unifi controller

Restore access to a unifi controller

When you are unable to login to the unifi controller or forgot admin password, you can restore access using SSH and manipulating mongodb directly.

Warning

Do not uninstall unifi controller - most of the data is not stored in mongodb. In case you thought a mongodb backup would be sufficient, you may have fucked up already, just like me. However I managed to write this "tutorial" for anyone to not run into the same trap.

Steps

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocal you use. And there're two common protocals: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocal. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
@nicksan2c
nicksan2c / secure-ssh.yml
Created March 15, 2020 12:44 — forked from cmavr8/secure-ssh.yml
Secure SSH configuration ansible playbook
---
# SSH server settings, in line with https://stribika.github.io/2015/01/04/secure-secure-shell.html
# Before using, change myhosts to your hosts' nickname and myuser to your username (two instances! make sure you replace both or you'll be locked out of ssh!)
- hosts: myhosts
become: true
remote_user: myuser
tasks:
# Key exchange, ciphers and MACs
- lineinfile: dest=/etc/ssh/sshd_config regexp='^KexAlgorithms' line='KexAlgorithms [email protected],diffie-hellman-group-exchange-sha256'
@nicksan2c
nicksan2c / ansbile_tips.yml
Created March 15, 2020 12:38 — forked from bmwant/ansbile_tips.yml
ansible quick tips for some modules
# Check existing
- name: Ansible check file exists.
stat:
path: /etc/filename
register: file_status
- debug:
msg: "File exists..."
when: file_status.stat.exists
- debug:
msg: "File not found"
@nicksan2c
nicksan2c / gist:6ac6af213e8a3ac68cf9a4b3c815176f
Created November 11, 2019 11:14 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@nicksan2c
nicksan2c / README.md
Created November 6, 2018 19:26 — forked from magnetikonline/README.md
Bash array usage cheatsheet.
@nicksan2c
nicksan2c / gdrive_download
Created April 16, 2018 03:59 — forked from darencard/gdrive_download
Script to download files from Google Drive using Bash
#!/usr/bin/env bash
# gdrive_download
#
# script to download Google Drive files from command line
# not guaranteed to work indefinitely
# taken from Stack Overflow answer:
# http://stackoverflow.com/a/38937732/7002068
gURL=$1
@nicksan2c
nicksan2c / transcode-install.sh
Created October 24, 2017 08:30 — forked from mmstick/transcode-install.sh
Ubuntu 10-bit HEVC Transcoding Tools -- Contains a script to install x265-10bit-git, libass-git, ffmpeg-git and bomi-git; another for updating everything; as well as scripts for transcoding videos with ffmpeg. Transcoding scripts require the fish shell to be installed.
#!/bin/bash
sourcedir="$HOME/.local/src/"
mkdir "$sourcedir"
export CFLAGS='-march=native -O3 -pipe -fstack-protector -Wall'
export CXXFLAGS='-march=native -O3 -pipe -fstack-protector -Wall'
function install-dependencies() {
# Install build tools and Mesa VDPAU support.
sudo apt-fast install -y cmake yasm autoconf build-essential mesa-vdpau-drivers \
libvdpau-va-gl1
@nicksan2c
nicksan2c / gist:645773057ba165a3576d0459ae1ba77d
Created April 16, 2017 20:49 — forked from waprin/gist:7aee67aefd7530d3587a
Verify Splunk Regex Matches Against Your Entire Log File
#!/usr/bin/env python
# usage ./verify_splunk_coverage.py <log_file>
# set these from splunk-apps/apps/<service-name>/default/props.conf
BREAK_ONLY_BEFORE_REGEX=r'^\d\d:\d\d:\d\d\s\[[^\]]+\]'
EXTRACT_REGEX=r'^\d?\d:\d\d:\d\d\s\[(?P<thread>[^\]]+)\]\s\[(?P<loglevel>\w+)\]\s\[(?P<class>[^\]]+)\]\s\[(?P<username>[^\]]*)\](?P<message>.*)$'
import re,sys
f = open(sys.argv[1])
@nicksan2c
nicksan2c / nullQueue Example
Created April 16, 2017 20:38 — forked from chrhuber/nullQueue Example
Splunk Summary Indexing Licence Usage
[debug_log_transform]
REGEX=DEBUG\s[
DEST_KEY = queue
FORMAT = nullQueue
Link https://answers.splunk.com/answers/11617/route-unwanted-logs-to-a-null-queue.html