From 20764a342a1b19b2393601bb7d03c1b21667e491 Mon Sep 17 00:00:00 2001 From: dabruh <11458706-dabruh@users.noreply.gitlab.com> Date: Sun, 5 Jun 2022 02:54:00 +0200 Subject: [PATCH] Automatically trigger BankID login through SSH. --- .local/bin/send-bankid-token | 14 ++++++++++++++ .local/share/applications/bankid.desktop | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 .local/bin/send-bankid-token diff --git a/.local/bin/send-bankid-token b/.local/bin/send-bankid-token new file mode 100755 index 0000000..cf36e43 --- /dev/null +++ b/.local/bin/send-bankid-token @@ -0,0 +1,14 @@ +#!/bin/bash + +# Takes a bankid URI as input, extracts the token and writes the token to disk +# on a target Windows SSH host. The target host is expected to watch for this +# file, just like the following PowerShell script does: +# https://gitlab.com/dabruh/weird-corner/-/blob/main/powershell/BankIDTokenFileWatcher.ps1 + +TOKEN=${1:?} || exit 1 +TOKEN="${TOKEN#*=}" +TOKEN="${TOKEN%&*}" + +xclip -selection clipboard <<<"$TOKEN" +ssh bankid -- powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "Set-Content -Path C:\.bidtoken -Value '$TOKEN'" & +notify-send BankID "Token has been sent." & diff --git a/.local/share/applications/bankid.desktop b/.local/share/applications/bankid.desktop index 823665e..3fcae3c 100644 --- a/.local/share/applications/bankid.desktop +++ b/.local/share/applications/bankid.desktop @@ -1,4 +1,4 @@ [Desktop Entry] Type=Application Name=BankID URI xclip -Exec=bash -c "xclip -selection clipboard <<<%u" +Exec=bash -c "send-bankid-token '%u'"