Service Configuration Review: Banners, TLS and SSH
Knowing that port 443 is open says little. The questions that produce findings are about how the service is configured: which software and version does it admit to, which TLS versions and cipher suites does it accept, is its certificate valid, does its SSH server allow passwords and root logins? A configuration review answers these from two directions: from the network, by talking to the service as a client, and from the inside, by reading its configuration files (when the scope includes them). This lesson does both for the three things almost every network has: banners, TLS and SSH.
Scope of the sessions: servers started inside the sandbox on 127.0.0.1 with the lab's own certificates.
Banners and headers
Many services announce themselves before you ask: SMTP and FTP greetings, SSH's version string, HTTP's Server header. The session reads the header of the sandbox's Python web server (the Date line is dropped because it changes).
python3 -m http.server 8000 --bind 127.0.0.1 >http.log 2>&1 &
for i in $(seq 50); do curl -s -o /dev/null http://127.0.0.1:8000/ && break; sleep 0.1; done
curl -sI http://127.0.0.1:8000/ | tr -d '\r' | grep -v '^Date:'
echo "--- the same through Nmap's http-headers script:"
nmap -sT -p 8000 --script http-headers 127.0.0.1 | grep -E '^\|' | grep -v 'Date:'
kill %1HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/3.12.3
Content-type: text/html; charset=utf-8
Content-Length: 398
--- the same through Nmap's http-headers script:
| http-headers:
| Server: SimpleHTTP/0.6 Python/3.12.3
| Content-type: text/html; charset=utf-8
| Content-Length: 398
|
|_ (Request type: HEAD)
SimpleHTTP/0.6 Python/3.12.3 names the exact runtime version. A version in a banner is evidence for the "outdated software" check, but weak evidence: distributions backport security fixes without changing the version string. Hiding banners (server_tokens off; in nginx, ServerTokens Prod in Apache) removes free information and some noise from mass scanners; it is a small hardening step, not a fix for an outdated server.
TLS: what to check
| Check | Good | Finding |
|---|---|---|
| Protocol versions | TLS 1.3, and TLS 1.2 where clients need it | SSL 3.0 (prohibited by RFC 7568), TLS 1.0 and TLS 1.1 (deprecated by RFC 8996) enabled |
| Cipher suites | AEAD suites (AES-GCM, ChaCha20-Poly1305) with forward secrecy (ECDHE) | static-RSA key exchange (TLS_RSA_WITH_…), CBC with SHA-1, 3DES, RC4, export or NULL suites |
| Certificate | valid dates, chains to a trusted CA, name matches (SAN), RSA ≥ 2048 or ECDSA P-256 | expired, self-signed in production, wrong name, SHA-1 signature |
| Extras | HSTS on web servers, OCSP stapling | missing HSTS on a site with logins |
The theory behind each line is in Applied Cryptography: the TLS 1.3 handshake, X.509 and chains, TLS limits. Here they become checks.
The session runs two TLS servers: a well-configured one with the lab certificate on 8443, and a "legacy" one on 9443 that only speaks TLS 1.2 with a static-RSA CBC suite and presents the expired lab certificate. It tests each protocol version against the legacy server, then verifies both against the lab CA.
openssl s_server -accept 127.0.0.1:8443 -cert $SAMPLES/pki/lab.test.crt -key $SAMPLES/pki/lab.test.key -quiet >/dev/null 2>&1 &
openssl s_server -accept 127.0.0.1:9443 -tls1_2 -cipher AES128-SHA \
-cert $SAMPLES/pki/expired.lab.test.crt -key $SAMPLES/pki/expired.lab.test.key -quiet >/dev/null 2>&1 &
for i in $(seq 50); do [ "$(ss -Htln | wc -l)" -ge 2 ] && break; sleep 0.1; done
for v in tls1_2 tls1_3; do
if openssl s_client -connect 127.0.0.1:9443 -$v </dev/null >/dev/null 2>&1; then r=accepted; else r=refused; fi
echo "9443 $v: $r"
done
echo "--- 9443 (legacy):"
openssl s_client -connect 127.0.0.1:9443 -brief -CAfile $SAMPLES/pki/ca.crt </dev/null 2>&1 | grep -E 'Protocol|Ciphersuite|Verification'
echo "--- 8443 (good):"
openssl s_client -connect 127.0.0.1:8443 -servername lab.test -brief -CAfile $SAMPLES/pki/ca.crt </dev/null 2>&1 | grep -E 'Protocol|Ciphersuite|Verification'
kill %1 %29443 tls1_2: accepted
9443 tls1_3: refused
--- 9443 (legacy):
Protocol version: TLSv1.2
Ciphersuite: AES128-SHA
Verification error: certificate has expired
--- 8443 (good):
Protocol version: TLSv1.3
Ciphersuite: TLS_AES_256_GCM_SHA384
Verification: OK
Three findings on 9443 in one screen: no TLS 1.3, a static-RSA key exchange with CBC and SHA-1 (AES128-SHA is OpenSSL's name for TLS_RSA_WITH_AES_128_CBC_SHA, no forward secrecy), and an expired certificate. The good server negotiates TLS 1.3 with an AEAD suite and verifies.
To enumerate everything a server accepts, Nmap's ssl-enum-ciphers script tries each version and suite in turn:
openssl s_server -accept 127.0.0.1:9443 -tls1_2 -cipher 'AES128-SHA:ECDHE-RSA-AES128-GCM-SHA256' \
-cert $SAMPLES/pki/expired.lab.test.crt -key $SAMPLES/pki/expired.lab.test.key -quiet >/dev/null 2>&1 &
for i in $(seq 50); do ss -Htln | grep -q ':9443' && break; sleep 0.1; done
nmap -sT -p 9443 --script ssl-enum-ciphers 127.0.0.1 | grep -E '^\|'
nmap -sT -p 9443 --script ssl-cert 127.0.0.1 | grep -E '^\|' | grep -vE 'MD5|SHA-1:' # separate runs: script order varies
kill %1| ssl-enum-ciphers:
| TLSv1.2:
| ciphers:
| TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (secp256r1) - A
| TLS_RSA_WITH_AES_128_CBC_SHA (rsa 2048) - A
| compressors:
| NULL
| cipher preference: client
|_ least strength: A
| ssl-cert: Subject: commonName=expired.lab.test/organizationName=ExcelTAD Lab/countryName=XX
| Subject Alternative Name: DNS:expired.lab.test
| Issuer: commonName=ExcelTAD Lab Root CA/organizationName=ExcelTAD Lab/countryName=XX
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2020-01-01T00:00:00
| Not valid after: 2021-01-01T00:00:00
Read the script's grades critically: it rated both suites "A" because it grades mainly by key and cipher strength, while a reviewer also flags TLS_RSA_WITH_AES_128_CBC_SHA for missing forward secrecy. Tools give evidence; the reviewer decides. Dedicated TLS scanners (testssl.sh, sslyze, SSL Labs for public sites) apply fuller rule sets.
SSH: reading the server configuration
The sandbox has no SSH server, so this part reviews configuration as text, which is also how an assessor with read access works (sshd -T prints the effective configuration on a real server, defaults included). The checker below applies a short hardening baseline to a lab server's sshd_config (synthetic). It honours the rule that for most keywords the first value wins in sshd_config.
CONFIG = """
# /etc/ssh/sshd_config on db.lab.test (export)
Port 22
PermitRootLogin yes
PasswordAuthentication yes
PasswordAuthentication no
KbdInteractiveAuthentication no
X11Forwarding yes
AllowTcpForwarding yes
MaxAuthTries 6
Ciphers aes128-ctr,aes256-gcm@openssh.com,3des-cbc
"""
BASELINE = { # keyword: (expected, why)
"permitrootlogin": ({"no", "prohibit-password"}, "no direct root logins with a password"),
"passwordauthentication": ({"no"}, "keys or certificates only"),
"x11forwarding": ({"no"}, "no X11 forwarding on servers"),
"allowtcpforwarding": ({"no", "local"}, "forwarding turns SSH into a tunnel through the firewall"),
"maxauthtries": (lambda v: int(v) <= 3, "limit guesses per connection"),
}
WEAK_CIPHERS = {"3des-cbc", "aes128-cbc", "aes256-cbc", "arcfour"}
seen = {}
for line in CONFIG.splitlines():
line = line.split("#", 1)[0].strip()
if not line:
continue
key, value = line.split(None, 1)
seen.setdefault(key.lower(), value) # first value wins
for key, (want, why) in BASELINE.items():
value = seen.get(key, "(default)")
ok = want(value) if callable(want) else value in want
print(f"{'ok ' if ok else 'FAIL'} {key} = {value:5} {'' if ok else '-> ' + why}")
weak = sorted(set(seen.get("ciphers", "").split(",")) & WEAK_CIPHERS)
print(f"{'FAIL' if weak else 'ok '} ciphers: weak = {weak}")FAIL permitrootlogin = yes -> no direct root logins with a password
FAIL passwordauthentication = yes -> keys or certificates only
FAIL x11forwarding = yes -> no X11 forwarding on servers
FAIL allowtcpforwarding = yes -> forwarding turns SSH into a tunnel through the firewall
FAIL maxauthtries = 6 -> limit guesses per connection
FAIL ciphers: weak = ['3des-cbc']
PasswordAuthentication appears twice: the reader of the file sees no at the end and believes passwords are off, but sshd takes the first value, yes. This is a real class of configuration mistake, and the reason to review the effective configuration (sshd -T) rather than the file. The fixes and their reasons are in Hardening the SSH Server; the protocol itself in SSH versus Telnet.
From the network side, two Nmap scripts read the same facts without credentials (lab session, scope 10.10.0.30):
assessor@kali:~$ nmap -sT -p 22 --script ssh-auth-methods,ssh2-enum-algos 10.10.0.30
PORT STATE SERVICE
22/tcp open ssh
| ssh-auth-methods:
| Supported authentication methods:
| publickey
|_ password
| ssh2-enum-algos:
| encryption_algorithms: (3)
| aes128-ctr
| aes256-gcm@openssh.com
|_ 3des-cbcHow configuration drift is detected
- Scheduled TLS and SSH scans of every listener, compared with the baseline (new weak suites, certificates close to expiry: alert 30 days ahead, certificate monitoring).
- Configuration management (Ansible, Puppet) applying the baseline and reporting differences; CIS Benchmarks as the reference checklist.
- Certificate Transparency monitoring for public names (CT and ACME).
How it is fixed
- TLS: enable TLS 1.2 and 1.3 only, ECDHE + AEAD suites, automated certificate renewal (ACME), HSTS on web applications. Mozilla's server-side TLS guidelines give tested configurations per server.
- SSH: keys or certificates only, no root logins, forwarding off unless needed, modern algorithms only, access through a bastion (Bastion Hosts).
- Banners: minimal version information, but patch regardless.
Pitfalls
- Testing only the default virtual host: servers with SNI present different certificates per name; pass
-servername. - Reviewing the file instead of the effective configuration (duplicates,
Includefiles,Matchblocks). - Treating a scanner's grade as the verdict.
- Breaking old clients without checking: find out who still needs TLS 1.2 or an old cipher, and plan the change.
Practice
1. A server accepts TLS 1.0, TLS 1.2 and TLS 1.3. Which finding do you write and what is the fix?
TLS 1.0 is deprecated (RFC 8996) and enables downgrade-era weaknesses; disable TLS 1.0 and 1.1 (ssl_protocols TLSv1.2 TLSv1.3; in nginx, MinProtocol = TLSv1.2 in OpenSSL configuration).
2. Change the SSH config so that every check passes. What did you change?
PermitRootLogin no, remove the first PasswordAuthentication yes, X11Forwarding no, AllowTcpForwarding no, MaxAuthTries 3, and Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-ctr (no 3des-cbc).
3. Why is TLS_RSA_WITH_AES_128_CBC_SHA a finding when the key is RSA 2048?
Static RSA key exchange has no forward secrecy: anyone who later obtains the server's private key can decrypt recorded sessions. It is also absent from TLS 1.3, and CBC with HMAC-SHA1 has a history of padding-oracle bugs.
Test yourself
Which TLS versions should a modern server accept?
- SSL 3.0 and up
- TLS 1.0 and up
- TLS 1.2 and TLS 1.3
- TLS 1.3 only, always
What did the session find on the legacy server 9443?
- Only an expired certificate
- No TLS 1.3, a static-RSA CBC suite and an expired certificate
- TLS 1.0
- Nothing wrong
An sshd_config has PasswordAuthentication yes on line 3 and PasswordAuthentication no on line 10. What does sshd use?
- no
- yes
- It refuses to start
- Whichever is in a Match block
How strong is evidence from a version banner?
- Proof of vulnerability
- A lead: banners can be changed, and distributions backport fixes without changing versions
- Useless
- Stronger than an authenticated check