Newer
Older
DirtyScripts / RS / 0FA.sh
root on 13 Jun 2022 1 KB (͠≖ ͜ʖ͠≖)👌
  1. #!/bin/bash
  2. #--- store google authenticator secret ---
  3. #╰» secret-tool store --label=GA_Name rshell secret
  4. #Password:
  5. #--- read GA secret ---
  6. #╰» secret-tool lookup rshell secret
  7. #--- how to use ---
  8. # 1. put the following in ~/.bashrc
  9. # 2. open a new terminal
  10. # 3. $> vpn2
  11. function vpn2 {
  12. D="$( date +%S )"
  13. P="0000" # *CHANGE THIS* to match your pin (goes before OTP)
  14. U="00000000-0000-0000-0000-000000000000" # *CHANGE THIS* to match your uuid (find with seahorse)
  15. X=$( secret-tool lookup username secret ) # https://manpages.ubuntu.com/manpages/xenial/man1/secret-tool.1.html
  16. Y=$( oathtool --totp -b "$X" ) # https://www.nongnu.org/oath-toolkit/man-oathtool.html
  17. active_con=$(nmcli con show --active | grep "Name" | wc -l) # if "Name" not currently connected
  18. if [ "${active_con}" = "0" ]; then
  19. # update the password in system keyring
  20. $( echo -n "$P$Y" | secret-tool store --label='VPN password secret for Name/org.freedesktop.NetworkManager.openvpn/vpn' setting-name vpn connection-uuid $U setting-key password )
  21. nmcli con up id RootShell2
  22. else
  23. if [ "${active_con}" = "1" ]; then
  24. printf "connected: $D: $P$Y\n"
  25. fi
  26. }
Buy Me A Coffee