Skip to content

Instantly share code, notes, and snippets.

View marcellourbani's full-sized avatar

Marcello Urbani marcellourbani

  • Basis Technologies
  • London, UK
View GitHub Profile
@marcellourbani
marcellourbani / otpresponder
Last active August 31, 2022 22:14
Automated OTP responder based on fish shell - maybe not a great idea but convenient :)
#!/usr/bin/fish
while true
set resp (inotifywait /run/systemd/ask-password -e moved_to)
set file = (string split ' ' $resp)
set pfile "/run/systemd/ask-password/$file[4]"
if grep "$CHALLENGE_KEY" $pfile >/dev/null
set socket (grep -i socket $pfile | sed s/socket=//i)
set ticket (oathtool -b --totp "$OTP_KEY")
echo socket "$socket"
echo "$ticket" | /lib/systemd/systemd-reply-password 1 "$socket"