Skip to content

Commit ecbb36f

Browse files
committed
Fix SSH MAC compatibility for Bitvise and older clients
sshtun-user configure may set MACs to ETM-only which breaks clients like Bitvise that only support non-ETM MACs. Now adds hmac-sha2-256 and hmac-sha2-512 as fallbacks while keeping ETM preferred. Fixes #19
1 parent 732ac13 commit ecbb36f

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

dnstm-setup.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,32 @@ generate_slipnet_url() {
10011001
echo "slipnet://$(echo -n "$data" | base64 -w0)"
10021002
}
10031003

1004+
# ─── SSH MAC Compatibility Fix ────────────────────────────────────────────────
1005+
1006+
fix_ssh_macs() {
1007+
# sshtun-user configure may set MACs to ETM-only, which breaks clients like
1008+
# Bitvise and older SSH clients that only support non-ETM MACs.
1009+
# Add SHA2 non-ETM fallbacks while keeping ETM preferred.
1010+
local sshd_config="/etc/ssh/sshd_config"
1011+
[[ -f "$sshd_config" ]] || return 0
1012+
1013+
# Check if MACs line exists and is ETM-only (no non-ETM fallbacks)
1014+
if grep -qE '^MACs\s+.*etm@openssh\.com' "$sshd_config" 2>/dev/null && \
1015+
! grep -qE '^MACs\s+.*hmac-sha2-256[^-]' "$sshd_config" 2>/dev/null; then
1016+
# Add non-ETM SHA2 fallbacks
1017+
sed -i 's/^\(MACs\s\+.*\)$/\1,hmac-sha2-256,hmac-sha2-512/' "$sshd_config"
1018+
# Validate before reloading
1019+
if command -v sshd &>/dev/null && sshd -t 2>/dev/null; then
1020+
systemctl reload sshd 2>/dev/null || systemctl reload ssh 2>/dev/null || true
1021+
print_ok "Added SSH MAC compatibility (non-ETM SHA2 fallbacks)"
1022+
else
1023+
# Rollback the change
1024+
sed -i 's/,hmac-sha2-256,hmac-sha2-512$//' "$sshd_config"
1025+
print_warn "SSH MAC fix failed validation — reverted"
1026+
fi
1027+
fi
1028+
}
1029+
10041030
# ─── microsocks GLIBC Fix ─────────────────────────────────────────────────────
10051031

10061032
compile_microsocks_from_source() {
@@ -2112,6 +2138,8 @@ do_manage_users() {
21122138
print_ok "Restored sshd_config from backup"
21132139
fi
21142140
fi
2141+
# Fix ETM-only MACs for client compatibility (Bitvise, older clients)
2142+
fix_ssh_macs
21152143
echo ""
21162144
fi
21172145

@@ -4784,6 +4812,9 @@ step_ssh_user() {
47844812
fi
47854813
fi
47864814

4815+
# Fix ETM-only MACs for client compatibility (Bitvise, older clients)
4816+
fix_ssh_macs
4817+
47874818
echo ""
47884819

47894820
# Get username

0 commit comments

Comments
 (0)