Skip to content

Instantly share code, notes, and snippets.

@lherich
lherich / yubikey-openpgp-for-ssh-authentication.md
Created March 19, 2017 19:54
Using an OpenPGP key on Yubikey Neo as a SSH key, fish shell v2.2.0, Elementarty OS Loki v0.4, gpg2 v2.1.11, gpg-agent v2.1.11

1. Install tools

  • gpg2, gpg-agent etc.

2. Generate OpenPGP keys (primary key and subkeys [sign&certify, encrypt and authentication])

3. Export OpenPGP keys into your Yubikey (|| Import OpenPGP keys into your Yubikey)

3. Make sure your public key is imported on your local machine

4. Add your ssh key to the remote server

  • Grep the ID for the subkey for authentication, e.g. ABCDEFFF
  • set subkeyId (gpg2 --list-secret-keys | grep '\[A\]' | cut -d'/' -f 2 | cut -d' ' -f 1)

Keybase proof

I hereby claim:

  • I am lherich on github.
  • I am lherich (https://keybase.io/lherich) on keybase.
  • I have a public key ASALobkLp6qdsZ7USXHeGdB_AxeJOySGtzylzLzTiDw3eQo

To claim this, I am signing this object:

@lherich
lherich / gist:37597f0df5ad40500d20d9d5e0ce93ee
Created April 15, 2016 09:06
Checkout git branch by grep
alias gitcheck=gitcheckFunc
gitcheckFunc() {
git branch | grep $1 | xargs git checkout
}
@lherich
lherich / Extend git branch by showing the last change date Raw
Created March 2, 2016 13:12
Extend git branch by showing the last change date
# source: http://stackoverflow.com/a/2514279
for k in `git branch -r | perl -pe 's/^..(.*?)( ->.*)?$/\1/'`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
git rm $(git ls-files --deleted)
git add $(git ls-files --modified)
@lherich
lherich / set-github-user-and-email
Last active September 14, 2015 23:28
Replace default git user and email by a specified value for all *.github.com repositories.
#!/bin/bash
#
# Replace default git user and email by a specified value
# for all *.github.com repositories.
#
# Installation:
# 1. Save this script to /usr/local/bin/set-github-user-and-email
# 2. Replace PUT_YOUR_NAME_HERE and PUT_YOUR_EMAIL_HERE
# 3. chmod 755 /usr/local/bin/set-github-user-and-email
# 4. alias git=/usr/local/bin/set-github-user-and-email
@lherich
lherich / ssh-host-color
Last active April 13, 2021 10:49
Automatically set random background color in iTerm depending on ssh host
#!/bin/bash
#!/bin/bash
#
# ssh into a machine and automatically set the background
# color of Mac OS X Terminal depending on the hostname.
#
# Installation:
# 1. Save this script to /usr/local/bin/ssh-host-color
# 2. chmod 755 /usr/local/bin/ssh-host-color
# 3. alias ssh=/usr/local/bin/ssh-host-color