Changes made in this version:
* Split into separate client and server packages * Cleaned up init file * Updated usher to support chroot into TARGET
This commit is contained in:
59
SNAP/usher
59
SNAP/usher
@@ -5,29 +5,50 @@ case $1 in
|
||||
exit 0
|
||||
;;
|
||||
postinst)
|
||||
if ! getent group sshd 2>&1 > /dev/null; then
|
||||
if groupadd -g 50 sshd; then
|
||||
echo 'Created group sshd'
|
||||
else
|
||||
echo 'Failed to create group sshd!'
|
||||
exit 1
|
||||
if [[ ${TARGET} ]]; then
|
||||
if ! chroot ${TARGET} 'getent group sshd 2>&1' > /dev/null; then
|
||||
if chroot ${TARGET} 'groupadd -g 50 sshd'; then
|
||||
echo 'Created group sshd'
|
||||
else
|
||||
echo 'Failed to create group sshd!'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! getent passwd sshd 2>&1 > /dev/null; then
|
||||
if useradd -c 'sshd PrivSep' -d /var/lib/sshd -g sshd \
|
||||
-s /bin/false -u 50 sshd; then
|
||||
echo 'Created user sshd'
|
||||
else
|
||||
echo 'Failed to create user sshd!'
|
||||
exit 1
|
||||
if ! chroot ${TARGET} 'getent passwd sshd 2>&1 > /dev/null'; then
|
||||
if chroot ${TARGET} 'useradd -c "sshd PrivSep" \
|
||||
-d /var/lib/sshd -g sshd -s /bin/false -u 50 sshd'; then
|
||||
echo 'Created user sshd'
|
||||
else
|
||||
echo 'Failed to create user sshd!'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
chown root:root /var/run/sshd
|
||||
if [ ! -f ${TARGET}/etc/ssh/ssh_host_rsa_key ]; then
|
||||
chroot ${TARGET} 'ssh-keygen -A'
|
||||
fi
|
||||
else
|
||||
if ! getent group sshd 2>&1 > /dev/null; then
|
||||
if groupadd -g 50 sshd; then
|
||||
echo 'Created group sshd'
|
||||
else
|
||||
echo 'Failed to create group sshd!'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if ! getent passwd sshd 2>&1 > /dev/null; then
|
||||
if useradd -c 'sshd PrivSep' -d /var/lib/sshd -g sshd \
|
||||
-s /bin/false -u 50 sshd; then
|
||||
echo 'Created user sshd'
|
||||
else
|
||||
echo 'Failed to create user sshd!'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
|
||||
ssh-keygen -A
|
||||
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
|
||||
ssh-keygen -A
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
prerm)
|
||||
|
||||
Reference in New Issue
Block a user