Fix IPv6 handling in ssh regen conf script

This commit is contained in:
Alexandre Aubin 2018-11-28 20:42:39 +00:00
parent 6a812190c5
commit 4db65682eb
2 changed files with 4 additions and 3 deletions

View file

@ -11,9 +11,9 @@ do_pre_regen() {
# Don't overwrite configuration if from_script
if [[ ! -f /etc/yunohost/from_script ]]; then
# do not listen to IPv6 if unavailable
[[ -f /proc/net/if_inet6 ]] \
|| sed -i "s/ListenAddress ::/#ListenAddress ::/g" sshd_config
[[ -f /proc/net/if_inet6 ]] && ipv6_enabled=true || ipv6_enabled=false
ssh_keys=$(ls /etc/ssh/ssh_host_{ed25519,rsa,ecdsa}_key 2>/dev/null)
@ -23,6 +23,7 @@ do_pre_regen() {
fi
export ssh_keys
export ipv6_enabled
ynh_render_template "sshd_config" "${pending_dir}/etc/ssh/sshd_config"
fi
}

View file

@ -4,7 +4,7 @@
Protocol 2
Port 22
ListenAddress ::
{% if ipv6_enabled == "true" %}ListenAddress ::{% endif %}
ListenAddress 0.0.0.0
{% for key in ssh_keys.split() %}