Browse Source

password manager

master
mort 8 years ago
parent
commit
eb7b7b9909
2 changed files with 67 additions and 3 deletions
  1. 63
    0
      bin/mpass
  2. 4
    3
      dotfiles/i3/config

+ 63
- 0
bin/mpass View File

@@ -0,0 +1,63 @@
#!/bin/bash

TMP_IN=$(mktemp /tmp/mpass.XXXXXXXXXX)
TMP_OUT=$(mktemp /tmp/mpass.XXXXXXXXXX)

function cleanup
{
rm "$TMP_IN" 2>&1 > /dev/null
rm "$TMP_OUT" 2>&1 > /dev/null
}

# Create password: mpass create <name> [chars]
if [ "$1" = "create" ]; then
if [ "$2" = "" ]; then
echo "Usage: mpass create <name> [chars]"
cleanup
exit 1
fi

if [ "$3" = "" ]; then
nchars="32"
else
nchars="$3"
fi

chars=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c "$nchars")

echo "$chars" > "$TMP_IN"
echo "$chars" | mclip

openssl enc -aes-256-cbc -salt -a -in "$TMP_IN" -out "$TMP_OUT" -pass "file:$HOME/.mpassword"

enc=$(cat "$TMP_OUT")

passsum=$(shasum -a 512 < ~/.mpassword | cut -d ' ' -f 1)

code=$(curl -s -X POST -d "$enc" "http://pass.mort.coffee/put/$2/$passsum")

if [ "$code" != "200" ]; then
echo "Error: $code"
cleanup
exit 1
fi

echo "$chars"

# Get password: mpass get <name>
elif [ "$1" = "get" ]; then
if [ "$2" = "" ]; then
echo "Usage: mpass get <name>"
cleanup
exit 1
fi

curl -s "http://pass.mort.coffee/get/$2" > $TMP_IN

openssl enc -aes-256-cbc -d -a -in "$TMP_IN" -out "$TMP_OUT" -pass "file:$HOME/.mpassword"

echo $(cat "$TMP_OUT") | mclip
echo $(cat "$TMP_OUT")
fi

cleanup

+ 4
- 3
dotfiles/i3/config View File

@@ -110,9 +110,6 @@ bindsym $mod+z layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
#bindsym $mod+a focus parent

@@ -188,4 +185,8 @@ bar {
}
}

bindsym $mod+space scratchpad show
for_window [instance="urxvt-scratchpad"] move scratchpad
exec urxvt -name "urxvt-scratchpad" -e tmux

exec sh ~/.wmrc

Loading…
Cancel
Save