diff --git a/modules/base.nix b/modules/base.nix index 2289dd5..f5df707 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -16,6 +16,6 @@ # age.secrets.secret1.file = ../secrets/secret1.age; -#environment.etc."secret1".source = config.age.secrets.secret1.path; +environment.etc."secret1".source = config.age.secrets.secret1.path; } diff --git a/modules/default.nix b/modules/default.nix index b35c445..a594671 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,6 +2,7 @@ imports = [ # New module organization ./gnome + ./wslsshagent ./base.nix ./ssh.nix ./user.nix diff --git a/modules/wslsshagent/default.nix b/modules/wslsshagent/default.nix new file mode 100644 index 0000000..9217362 --- /dev/null +++ b/modules/wslsshagent/default.nix @@ -0,0 +1,12 @@ +{ lib, config, pkgs, ... }: { + + #define option to enable this + options.mymods.wslsshagent.enable = lib.mkEnableOption "Enable WSL Agent forwarder"; + + config = lib.mkIf config.mymods.wslsshagent.enable { + +### + + +}; +} \ No newline at end of file diff --git a/modules/wslsshagent/wsl-ssh-agent-forwarder b/modules/wslsshagent/wsl-ssh-agent-forwarder new file mode 100644 index 0000000..6aae2aa --- /dev/null +++ b/modules/wslsshagent/wsl-ssh-agent-forwarder @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Usage: wsl-ssh-agent-forward [ -k | -r ] +# Options: +# -k Kill the current process (if exists) and do not restart it. +# -r Kill the current process (if exists) and restart it. +# Default operation is to start a process only if it does not exist. + +export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock + +sshpid=$(ss -ap | grep "$SSH_AUTH_SOCK") +if [ "$1" = "-k" ] || [ "$1" = "-r" ]; then + sshpid=${sshpid//*pid=/} + sshpid=${sshpid%%,*} + if [ -n "${sshpid}" ]; then + kill "${sshpid}" + else + echo "'socat' not found or PID not found" + fi + if [ "$1" = "-k" ]; then + exit + fi + unset sshpid +fi + +if [ -z "${sshpid}" ]; then + rm -f $SSH_AUTH_SOCK + ( setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$HOME/bin/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork & ) >/de>fi \ No newline at end of file