Fuck
This commit is contained in:
parent
561e273c1a
commit
c5af71c22a
13
home/ssh.nix
13
home/ssh.nix
@ -1,28 +1,31 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
# Enable SSH client and add to agent automatically
|
|
||||||
programs.ssh = {
|
programs.ssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
addKeysToAgent = "yes";
|
addKeysToAgent = "yes";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Per-user ssh-agent (systemd --user)
|
|
||||||
services.ssh-agent.enable = true;
|
services.ssh-agent.enable = true;
|
||||||
|
|
||||||
# Systemd unit to load all private keys from ~/.ssh
|
|
||||||
systemd.user.services."ssh-add-all-keys" = {
|
systemd.user.services."ssh-add-all-keys" = {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Add all SSH keys from ~/.ssh to ssh-agent";
|
Description = "Add all SSH keys from ~/.ssh to ssh-agent";
|
||||||
After = [ "ssh-agent.service" ];
|
After = [ "ssh-agent.service" ];
|
||||||
Requires = [ "ssh-agent.service" ];
|
Requires = [ "ssh-agent.service" ];
|
||||||
|
# Skip running if there are no id_* keys:
|
||||||
|
ConditionPathExistsGlob = "%h/.ssh/id_*";
|
||||||
};
|
};
|
||||||
Service = {
|
Service = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
Environment = [ "SSH_ASKPASS_REQUIRE=prefer" ];
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.openssh}/bin/ssh-add -q ~/.ssh/id_* 2>/dev/null || true
|
${pkgs.bash}/bin/bash -lc '${pkgs.openssh}/bin/ssh-add -q %h/.ssh/id_* 2>/dev/null || true'
|
||||||
'';
|
'';
|
||||||
|
# Make it non-interactive (don’t pop up askpass):
|
||||||
|
Environment = [
|
||||||
|
"SSH_ASKPASS=/bin/false"
|
||||||
|
"DISPLAY=ignored"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
Install.WantedBy = [ "default.target" ];
|
Install.WantedBy = [ "default.target" ];
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user