sshd: allow adding user options in /data/etc/sshd_config

This commit is contained in:
Calin Crisan 2020-01-20 22:26:44 +02:00
parent 9c96f22ed0
commit e7f6389780
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
CONF="/etc/sshd_config" SYS_CONF="/etc/sshd_config"
USER_CONF="/data/etc/sshd_config"
CONF="/var/run/sshd_config"
PROG="/usr/sbin/sshd" PROG="/usr/sbin/sshd"
PROG_KG="/usr/bin/ssh-keygen" PROG_KG="/usr/bin/ssh-keygen"
@ -10,7 +12,7 @@ test -x ${PROG} || exit 0
test -n "${OS_VERSION}" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
test -s ${CONF} || exit 0 test -s ${SYS_CONF} || exit 0
test "${OS_NETWORKLESS}" == "true" && exit 0 test "${OS_NETWORKLESS}" == "true" && exit 0
@ -18,6 +20,13 @@ test "${OS_NETWORKLESS}" == "true" && exit 0
start() { start() {
msg_begin "Starting sshd" msg_begin "Starting sshd"
# merge user and sys conf files; options in first file take precedence
if [[ -s ${USER_CONF} ]]; then
cat ${USER_CONF} ${SYS_CONF} > ${CONF}
else
cp ${SYS_CONF} ${CONF}
fi
# create any missing keys # create any missing keys
if ! ${PROG_KG} -A >/dev/null; then if ! ${PROG_KG} -A >/dev/null; then
msg_fail msg_fail
@ -57,4 +66,3 @@ case "$1" in
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop|restart}"
exit 1 exit 1
esac esac

View File

@ -1,4 +1,3 @@
Port 22
ListenAddress 0.0.0.0 ListenAddress 0.0.0.0
HostKey /data/etc/ssh_host_rsa_key HostKey /data/etc/ssh_host_rsa_key