nixpkgs/upstart-jobs/sshd.nix
Eelco Dolstra b7f11ad98b * Generate sshd_config to set XAuthLocation if X11 forwarding is
enabled.

svn path=/nixos/trunk/; revision=7548
2007-01-07 10:19:16 +00:00

45 lines
901 B
Nix

{writeText, openssh, glibc, pwdutils, xauth, forwardX11}:
let
sshdConfig = writeText "sshd_config" "
UsePAM yes
${if forwardX11 then "
X11Forwarding yes
XAuthLocation ${xauth}/bin/xauth
" else "
X11Forwarding no
"}
";
in
{
name = "sshd";
job = "
description \"SSH server\"
start on network-interfaces/started
stop on network-interfaces/stop
start script
mkdir -m 0555 -p /var/empty
mkdir -m 0755 -p /etc/ssh
if ! test -f /etc/ssh/ssh_host_dsa_key; then
${openssh}/bin/ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
fi
if ! ${glibc}/bin/getent passwd sshd > /dev/null; then
${pwdutils}/sbin/useradd -g nogroup -d /var/empty -s /noshell \\
-c 'SSH privilege separation user' sshd
fi
end script
respawn ${openssh}/sbin/sshd -D -h /etc/ssh/ssh_host_dsa_key -f ${sshdConfig}
";
}