Compare commits

...
4 Commits
13 changed files with 43 additions and 39 deletions
-1
View File
@@ -2,7 +2,6 @@
# shellcheck disable=SC1090 # shellcheck disable=SC1090
[[ -f ~/.bashrc ]] && . ~/.bashrc [[ -f ~/.bashrc ]] && . ~/.bashrc
export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket"
export _JAVA_AWT_WM_NONREPARENTING=1 export _JAVA_AWT_WM_NONREPARENTING=1
if [[ -z "${DISPLAY}" ]] && [[ "${XDG_VTNR}" -eq 1 ]]; then if [[ -z "${DISPLAY}" ]] && [[ "${XDG_VTNR}" -eq 1 ]]; then
-6
View File
@@ -97,12 +97,6 @@ export JUPYTERLAB_DIR=$HOME/.local/share/jupyter/lab
# Zettelkasten {{{ # Zettelkasten {{{
export ZK_PATH="$HOME/.zk" export ZK_PATH="$HOME/.zk"
# SSH Agent {{{
if [[ -z "${SSH_CONNECTION}" ]]; then
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
fi
# }}}
# Codi # Codi
# Usage: codi [filetype] [filename] # Usage: codi [filetype] [filename]
@@ -1,10 +0,0 @@
[Unit]
Description=SSH Key agent
[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
[Install]
WantedBy=default.target
+1 -1
View File
@@ -1,6 +1,6 @@
# `colmena` wrapper script that opens a short-lived SSH master process for # `colmena` wrapper script that opens a short-lived SSH master process for
# `colmena` to use so it works with hardware-backed key touch+PIN. assumes # `colmena` to use so it works with hardware-backed key touch+PIN. assumes
# ControlPath ~/.ssh/socket-%r@%h:%p (see ./default.nix) # ControlPath ~/.ssh/control/%C (see ../ssh/default.nix)
selector="" selector=""
want_on=0 want_on=0
-11
View File
@@ -61,16 +61,5 @@ in
colmenaWrapped colmenaWrapped
deployRsWrapped deployRsWrapped
]; ];
programs.ssh.settings = lib.genAttrs hostsWithKeys (
hostname:
let
meta = myUtils.hostMeta (hostDir + "/${hostname}");
in
{
User = meta.host.username;
HostName = hostname;
ControlPath = "~/.ssh/socket-%r@%h:%p";
}
);
}; };
} }
+1 -1
View File
@@ -1,6 +1,6 @@
# `deploy` wrapper script that opens a short-lived SSH master process for # `deploy` wrapper script that opens a short-lived SSH master process for
# `deploy-rs` to use so it works with hardware-backed key touch+PIN. assumes # `deploy-rs` to use so it works with hardware-backed key touch+PIN. assumes
# ControlPath ~/.ssh/socket-%r@%h:%p (see ./default.nix) # ControlPath ~/.ssh/control/%C (see ../ssh/default.nix)
# extract the target host from the `deploy-rs` flake target (e.g. `.#hecuba`) # extract the target host from the `deploy-rs` flake target (e.g. `.#hecuba`)
node="" node=""
+1
View File
@@ -15,6 +15,7 @@ in
enable = true; enable = true;
settings = { settings = {
Browser.Enabled = true; Browser.Enabled = true;
SSHAgent.Enabled = true;
}; };
}; };
}; };
+39 -9
View File
@@ -2,11 +2,17 @@
config, config,
lib, lib,
pkgs, pkgs,
myUtils,
... ...
}: }:
let let
cfg = config.ssh; cfg = config.ssh;
hostDir = ../../../hosts;
hostsWithKeys = lib.filter (hostname: builtins.pathExists (hostDir + "/${hostname}/ssh_host.pub")) (
myUtils.dirNames hostDir
);
in in
{ {
options.ssh.enable = lib.mkEnableOption "ssh"; options.ssh.enable = lib.mkEnableOption "ssh";
@@ -14,20 +20,44 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = with pkgs; [ sshfs ]; home.packages = with pkgs; [ sshfs ];
home.file.".ssh/control/.keep".text = "";
services.ssh-agent.enable = true;
systemd.user.services.ssh-agent.Service.Environment = [
"SSH_ASKPASS=${pkgs.lxqt.lxqt-openssh-askpass}/bin/lxqt-openssh-askpass"
"SSH_ASKPASS_REQUIRE=prefer"
];
programs.ssh = { programs.ssh = {
enable = true; enable = true;
enableDefaultConfig = false; enableDefaultConfig = false;
settings = { settings =
"*" = { lib.genAttrs hostsWithKeys (
AddKeysToAgent = "yes"; hostname:
ForwardAgent = false; let
identityFile = [ meta = myUtils.hostMeta (hostDir + "/${hostname}");
"~/.ssh/id_ed25519_sk" in
"~/.ssh/id_ed25519_sk_bak" {
]; User = meta.host.username;
HostName = hostname;
}
)
// {
"*" = {
AddKeysToAgent = "yes";
ForwardAgent = false;
identityFile = [
"~/.ssh/id_ed25519_sk"
"~/.ssh/id_ed25519_sk_bak"
];
IdentitiesOnly = true;
ControlMaster = "auto";
ControlPath = "~/.ssh/control/%C";
ControlPersist = "10m";
};
}; };
};
}; };
}; };
} }
+1
View File
@@ -20,6 +20,7 @@ in
services.openssh.settings = optionalAttrs cfg.harden { services.openssh.settings = optionalAttrs cfg.harden {
PermitRootLogin = "no"; PermitRootLogin = "no";
PasswordAuthentication = false; PasswordAuthentication = false;
AuthenticationMethods = "publickey";
KbdInteractiveAuthentication = false; KbdInteractiveAuthentication = false;
ChallengeResponseAuthentication = false; ChallengeResponseAuthentication = false;
X11Forwarding = false; X11Forwarding = false;