Disable the SSH server is 'PORT_SSH' variable is set to an empty string
This commit is contained in:
@@ -1,14 +1,21 @@
|
|||||||
|
|
||||||
# Generate new SSH host keys if they dont exist
|
echo "**** Configure SSH server ****"
|
||||||
if [[ ! -f /etc/ssh/ssh_host_rsa_key ]]; then
|
|
||||||
echo "**** Generating SSH keys ****";
|
if [[ "X${PORT_SSH:-}" != "X" ]]; then
|
||||||
/usr/bin/ssh-keygen -A
|
# Generate new SSH host keys if they dont exist
|
||||||
|
if [[ ! -f /etc/ssh/ssh_host_rsa_key ]]; then
|
||||||
|
echo "**** Generating SSH keys ****";
|
||||||
|
/usr/bin/ssh-keygen -A
|
||||||
|
fi
|
||||||
|
mkdir -p /run/sshd
|
||||||
|
chmod 744 /run/sshd
|
||||||
|
|
||||||
|
echo "Set port to '${PORT_SSH}'"
|
||||||
|
sed -i "s|^# Port 22.*$|Port ${PORT_SSH}|" /etc/ssh/ssh_config
|
||||||
|
else
|
||||||
|
echo "Disable SSH server"
|
||||||
|
# Disable supervisord script
|
||||||
|
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/sshd.ini
|
||||||
fi
|
fi
|
||||||
mkdir -p /run/sshd
|
|
||||||
chmod 744 /run/sshd
|
|
||||||
|
|
||||||
echo "**** Configure SSH service ****";
|
|
||||||
|
|
||||||
sed -i "s|^# Port 22.*$|Port ${PORT_SSH}|" /etc/ssh/ssh_config
|
|
||||||
|
|
||||||
echo "DONE"
|
echo "DONE"
|
||||||
|
|||||||
Reference in New Issue
Block a user