2007-01-10 17:19:17 +00:00
|
|
|
{ writeText, openssh, glibc, pwdutils, xauth
|
2007-01-15 17:19:41 +00:00
|
|
|
, nssModulesPath
|
2007-01-10 17:19:17 +00:00
|
|
|
, forwardX11, allowSFTP
|
|
|
|
}:
|
2007-01-07 10:19:16 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
sshdConfig = writeText "sshd_config" "
|
|
|
|
UsePAM yes
|
2007-01-10 17:19:17 +00:00
|
|
|
|
2007-01-07 10:19:16 +00:00
|
|
|
${if forwardX11 then "
|
|
|
|
X11Forwarding yes
|
|
|
|
XAuthLocation ${xauth}/bin/xauth
|
|
|
|
" else "
|
|
|
|
X11Forwarding no
|
|
|
|
"}
|
2007-01-10 17:19:17 +00:00
|
|
|
|
|
|
|
${if allowSFTP then "
|
|
|
|
Subsystem sftp ${openssh}/libexec/sftp-server
|
|
|
|
" else "
|
|
|
|
"}
|
|
|
|
|
2007-01-07 10:19:16 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
in
|
2006-11-23 17:43:28 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
name = "sshd";
|
|
|
|
|
|
|
|
job = "
|
|
|
|
description \"SSH server\"
|
|
|
|
|
|
|
|
start on network-interfaces/started
|
|
|
|
stop on network-interfaces/stop
|
|
|
|
|
2007-01-15 17:19:41 +00:00
|
|
|
env LD_LIBRARY_PATH=${nssModulesPath}
|
|
|
|
|
2006-11-23 17:43:28 +00:00
|
|
|
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
|
|
|
|
|
2006-12-18 15:52:43 +00:00
|
|
|
if ! ${glibc}/bin/getent passwd sshd > /dev/null; then
|
2006-12-18 15:48:29 +00:00
|
|
|
${pwdutils}/sbin/useradd -g nogroup -d /var/empty -s /noshell \\
|
|
|
|
-c 'SSH privilege separation user' sshd
|
2006-11-23 17:43:28 +00:00
|
|
|
fi
|
|
|
|
end script
|
|
|
|
|
2007-01-07 10:19:16 +00:00
|
|
|
respawn ${openssh}/sbin/sshd -D -h /etc/ssh/ssh_host_dsa_key -f ${sshdConfig}
|
2006-11-23 17:43:28 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
}
|