mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
* Add an Upstart job for sshd. The start script automatically creates
an sshd user, a host key, etc. svn path=/nixu/trunk/; revision=7096
This commit is contained in:
parent
a0821fbd49
commit
e6ebe2e2aa
3 changed files with 38 additions and 0 deletions
|
@ -102,6 +102,11 @@ rec {
|
||||||
dhcp = pkgs.dhcpWrapper;
|
dhcp = pkgs.dhcpWrapper;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# SSH daemon.
|
||||||
|
(import ./upstart-jobs/sshd.nix {
|
||||||
|
inherit (pkgs) openssh;
|
||||||
|
})
|
||||||
|
|
||||||
# Handles the maintenance/stalled event (single-user shell).
|
# Handles the maintenance/stalled event (single-user shell).
|
||||||
(import ./upstart-jobs/maintenance-shell.nix {
|
(import ./upstart-jobs/maintenance-shell.nix {
|
||||||
inherit (pkgs) bash;
|
inherit (pkgs) bash;
|
||||||
|
|
|
@ -93,6 +93,7 @@ fi
|
||||||
# Set up the Upstart jobs.
|
# Set up the Upstart jobs.
|
||||||
export UPSTART_CFG_DIR=/etc/event.d
|
export UPSTART_CFG_DIR=/etc/event.d
|
||||||
|
|
||||||
|
rm -f /etc/event.d
|
||||||
ln -sf @upstartJobs@/etc/event.d /etc/event.d
|
ln -sf @upstartJobs@/etc/event.d /etc/event.d
|
||||||
|
|
||||||
|
|
||||||
|
|
32
test/upstart-jobs/sshd.nix
Normal file
32
test/upstart-jobs/sshd.nix
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{openssh}:
|
||||||
|
|
||||||
|
{
|
||||||
|
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
|
||||||
|
|
||||||
|
echo 'X11Forwarding yes' > /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
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 ! grep -q '^sshd:' /etc/passwd; then
|
||||||
|
echo 'sshd:x:74:74:SSH privilege separation user:/var/empty:/noshell' >> /etc/passwd
|
||||||
|
fi
|
||||||
|
|
||||||
|
end script
|
||||||
|
|
||||||
|
respawn ${openssh}/sbin/sshd -h /etc/ssh/ssh_host_dsa_key -f /etc/ssh/sshd_config
|
||||||
|
";
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue