This commit is contained in:
Martin Benonisen 2024-03-20 15:15:46 +01:00
parent dd91744445
commit a239632816
Signed by: mbeno
SSH Key Fingerprint: SHA256:iAzOA1WUAxocdh/WRWXcSg5nw2dJ1aDCvPuT+3ZjkwI
3 changed files with 51 additions and 0 deletions

View File

@ -19,6 +19,7 @@
./zsh ./zsh
./packages ./packages
./ssh ./ssh
./services/ssh-office.nix
]; ];
firefox.enable = true; firefox.enable = true;
tmux.enable = true; tmux.enable = true;

View File

@ -2,6 +2,7 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
# Generic tools # Generic tools
age age
discord
alacritty alacritty
unstable.btop unstable.btop
bzip2 bzip2
@ -75,5 +76,9 @@
# Rust # Rust
rustup rustup
# homemade
sshotp
ssh-dresden
]; ];
} }

View File

@ -0,0 +1,45 @@
{ pkgs, config, ...}:
let
sshotp = pkgs.writeScriptBin "sshotp"
''
#!/usr/bin/env expect
set stty_init -echo
set timeout 300
set totp [lindex $argv 0];
puts "Our TOTP $totp"
spawn ssh -D 20000 dresden.uio.no
expect {
-re {.*(Verification_Code):} {
send -- "$totp\r"
exp_continue
}
-re {.*dresden.*} {
wait
}
}
'';
ssh-dresden = pkgs.writeShellApplication {
name = "ssh-dresden";
runtimeInputs = [ pkgs.rbw pkgs.expect ];
text = ''
#!/usr/bin/env bash
totp=$(rbw get -f "TOTP" rlogin)
expect -f ${sshotp}/bin/sshotp "$totp"
'';
};
in
{
systemd.user.services.ssh-office = {
Unit = {
Description = "Office ssh session";
};
Service = {
Type = "simple";
ExecStart = "${ssh-dresden}/bin/ssh-dresden";
};
Install = {
WantedBy = [ "default.target" ];
};
};
}