Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #
  2. # Keepass to Pass database converter
  3. # ----------------------------------
  4. #
  5. # Convert Keepass .csv export to valid gpg
  6. # files in the .password-store directory
  7. #
  8. # Usage:
  9. # ./keepasstopass.sh -i [mydatabase.csv] -u [gpg_user]
  10. #
  11.  
  12. OPTS=`getopt -o ui: --long user,input-file: -n 'parse-options' -- "$@"`
  13.  
  14. if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
  15.  
  16. while true; do
  17. case "$1" in
  18. -u | --user ) USER="$2"; shift ; shift ;;
  19. -i | --input-file ) INPUT_FILE="$2"; shift; shift ;;
  20. -- ) shift; break ;;
  21. * ) break ;;
  22. esac
  23. done
  24. echo $USER
  25.  
  26. for line in $(cat $INPUT_FILE); do
  27. CREDENTIALS=$(echo $line | tr -d \" | cut -d , -f 1-3)
  28. OUTFILE=$(echo $CREDENTIALS | cut -d , -f 1)
  29. USERNAME=$(echo $CREDENTIALS | cut -d , -f 2)
  30. PASSWORD=$(echo $CREDENTIALS | cut -d , -f 3)
  31.  
  32. read -d '' DATA << EOF
  33. $PASSWORD
  34. Username: $USERNAME
  35. EOF
  36.  
  37. cd ~/.password-store
  38. echo "$DATA" | gpg -e -r $USER -o $OUTFILE
  39. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement