Send a Command Using OpenSSL

openssl s_client is an SSL/TLS client that can also be used to talk to plaintext services when no other tool is available. The -ign_eof flag is the critical piece: it prevents s_client from closing the connection when stdin reaches EOF.

echo "$TEXT" | openssl s_client $HOST:$PORT -ign_eof

Why -ign_eof matters

Without -ign_eof, openssl s_client terminates as soon as stdin closes — which happens immediately after echo finishes writing. The server never has time to respond. -ign_eof keeps the client alive, letting you read the server’s reply before the connection drops.

Practical uses

  • Testing TLS services: Verify certificate chains, cipher suites, and protocol versions against a server.
  • Banner grabbing: Some TLS-wrapped services (SMTPS, IMAPS, POP3S) send banners after the handshake; -ign_eof lets you see them.
  • Manual protocol debugging: Send raw HTTP, SMTP, or IMAP commands over TLS when telnet or nc can’t do SSL.

Example: TLS-wrapped HTTP

echo -e "GET / HTTP/1.1\r\nHost: $HOST\r\nConnection: close\r\n\r\n" | openssl s_client -connect $HOST:443 -ign_eof

Sources