Skip to content

Instantly share code, notes, and snippets.

@Shourai
Shourai / Allowing SSH on a server with an active OpenVPN client.md
Last active October 5, 2023 06:32
Allowing SSH on a server with an active OpenVPN client

If you want to SSH to a VPS which is running openVPN do the following:
source: https://serverfault.com/questions/659955/allowing-ssh-on-a-server-with-an-active-openvpn-client

Enable

The problem is that the default gateway gets changed by OpenVPN, and that breaks your current SSH connection unless you set up appropriate routes before you start OpenVPN.

What follows works for me. It uses iptables and ip (iproute2). Below, it is assumed that the default gateway interface before OpenVPN is started is "eth0". The idea is to ensure that when a connection to eth0 is made, even if eth0 is not the default gateway interface anymore, response packets for the connection go back on eth0 again.

You could use the same number for the connection mark, firewall mark and routing table. I used distinct numbers to make the diffences between them more apparent.

@Shourai
Shourai / Raspberry Pi headless installation.md
Last active October 15, 2017 20:46
Raspberry Pi headless installation

SSH over USB

To edit files on a raspberry pi when you are unable to mount ext4 disks, it is possible to enable SSH over USB. This is also useful if you do not have any peripherals you can attach to the pi. If however you are running linux you can directly edit /etc/wpa_supplicant/wpa_supplicant.conf, etc/network/interfaces and /etc/dhcpcd.conf.

Enable SSH

There was a security update to the Raspian images. To enable ssh you need to put a blank ssh file in the boot directory.

@Shourai
Shourai / git prompt in zsh
Last active October 18, 2018 08:23
git prompt in zsh
# Adapted from https://joshdick.net/2017/06/08/my_git_prompt_for_zsh_revisited.html
# PROMPT='%~ ❯ '
setopt prompt_subst
autoload -U colors && colors # Enable colors in prompt
# Echoes a username/host string when connected over SSH (empty otherwise)
ssh_info() {
[[ "$SSH_CONNECTION" != '' ]] && echo "%(!.%{$fg[red]%}.%{$fg[yellow]%})%n%{$reset_color%}@%{$fg[green]%}%m%{$reset_color%}:" || echo ""
## enable changes inside brackets e.g. <di+)>, <ci+[>
# autoload -U select-bracketed
# autoload -U select-quoted
# zle -N select-quoted
# zle -N select-bracketed
# for km in visual viopp; do
# bindkey -M $km -- '-' vi-up-line-or-history
# for c in {a,i}${(s..)^:-\'\"\`\|,./:;-=+@}; do
# bindkey -M $km $c select-quoted
# done
@Shourai
Shourai / Nightshift mac
Last active March 29, 2017 08:29
Nightshift on unsupported macs
This was written by Ryanmcv over at https://pikeralpha.wordpress.com/2017/01/30/4398/comment-page-1/#comment-9146
1. Disable System Integrity Protection by booting into Recovery mode (hold down Command + R during boot-up), opening Terminal, and typing csrutil disable
2. Restart your Mac and open Finder. Navigate to System/Library/PrivateFrameworks/
Make a copy of the entire CoreBrightness.framework folder (save it to your desktop or a similar place).
3. In Xcode, open the copy of CoreBrightness.framework that you just created. File > Open; Browse to where you just saved CoreBrightness.framework; from within that .framework folder, choose the CoreBrightness icon at the top that looks like a shortcut.
4. In Xcode, press Shift + Command + J on your keyboard. A navigation column will appear on the left-hand side. Secondary/right-click CoreBrightness at the top of that column and choose Open As > Hex.
@Shourai
Shourai / Android platform tools
Created January 8, 2017 20:51
Latest android platform tools (ADB and Fastboot) Raw
Ever wanted to download adb or fastboot without having to download the whole of Android Studio?
...but didn't want to download executables from some random warez site?
Good news this week:
https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
https://dl.google.com/android/repository/platform-tools-latest-linux.zip
@Shourai
Shourai / adb.sh
Last active August 19, 2020 08:34 — forked from olivier-m/adb.sh
Remove all Google apps from an android phone/tablet (Nexus 5 / Nexus 9 | Marshmallow 6.0.1).
# With your phone in debug mode, etc.
adb start-server
adb remount
adb shell < remove.sh