summaryrefslogtreecommitdiff
path: root/overlays
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2021-12-08 15:23:37 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2021-12-08 15:23:37 +0100
commita2962229c6a81ac23a685d243fa43d83957b4fc4 (patch)
treeda76b91033b595d202ef76eee81d15adc1a0f1db /overlays
parentf7bfa8f38cba7da1fb54bcf9e778b4dafeea967e (diff)
downloadnixos-a2962229c6a81ac23a685d243fa43d83957b4fc4.tar
nixos-a2962229c6a81ac23a685d243fa43d83957b4fc4.tar.gz
nixos-a2962229c6a81ac23a685d243fa43d83957b4fc4.tar.bz2
nixos-a2962229c6a81ac23a685d243fa43d83957b4fc4.tar.xz
nixos-a2962229c6a81ac23a685d243fa43d83957b4fc4.zip
gkleen@sif: systemd-based ssh socks proxy
Diffstat (limited to 'overlays')
-rw-r--r--overlays/sshpass-secret.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/overlays/sshpass-secret.nix b/overlays/sshpass-secret.nix
new file mode 100644
index 00000000..cfd19afe
--- /dev/null
+++ b/overlays/sshpass-secret.nix
@@ -0,0 +1,26 @@
1final: prev: {
2 sshpassSecret = prev.writeScriptBin "sshpass-secret" ''
3 #!${final.zsh}/bin/zsh -e
4
5 typeset -a cmd
6 cmd=()
7
8 while
9 if [[ "$#" -le 0 ]]; then
10 echo "Insufficient arguments" >&2
11 exit 2
12 fi
13 arg="''${1}"
14 shift
15 do
16 [[ "''${arg}" == '--' ]] && break
17 user=''${arg%@*}
18 host=''${arg#*@}
19 exec {fdnum}< <(${final.gnome.libsecret}/bin/secret-tool lookup service sshpass host "''${host}" user "''${user}")
20 cmd+=(${final.sshpass}/bin/sshpass -d ''${fdnum} -P "''${user}@''${host}'s password:")
21 done
22
23 cmd+=($@)
24 exec -a ''${cmd[1]} -- $cmd
25 '';
26}