From 94cbb7fcc713413b7df4c7c35876561e153d6ad0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 18 May 2011 15:04:08 -0400 Subject: [PATCH] Add simple servers post. --- posts/Simple_servers.mdwn | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 posts/Simple_servers.mdwn diff --git a/posts/Simple_servers.mdwn b/posts/Simple_servers.mdwn new file mode 100644 index 0000000..83dfd8b --- /dev/null +++ b/posts/Simple_servers.mdwn @@ -0,0 +1,47 @@ +After reading Brian Hatch's [Nmap Version Detection Rocks][nmap], I +wanted to set up a simple socket-connection test. Here are my notes: + +Start a plain-text socket echoing incomming text using [netcat][]: + + a$ nc -l -p 8080 a.example.net + +The `-l` (listen) switches netcat into server mode. + +Echo text to that port + + b$ echo 'hi there' | nc -q 1 a.example.net 8080 + +The `-q 1` tells netcat to quit after an EOF is detected. When the +client quits, the connection breaks, and the server goes down on its +own. If you want netcat to stay up you'll have to restart it: + + $ $ while nc -l -p 8080 tyr; do :; done + +The `:` is Bash's noop. + + +For a secure connection, use [OpenSSL][] (see [[X.509_certificate]] +for more on generating keys and certificates): + + a$ openssl s_server -key key.pem -cert cert.pem -accept 8080 + +Connect with + + b$ echo 'hi there' | openssl s_client -connect a.example.net:8080 + +The OpenSSH client automatically closes on EOF, but the server stays +open for new connections. You'll have to kill it manually when you're +done. + +If you don't like OpenSSL, you can also use [stunnel][] for SSL +connections. Examples are all over. [This post][DB] by Dustin Breese +seems good. + +[nmap]: http://www.hackinglinuxexposed.com/articles/20031006.html +[netcat]: http://nc110.sourceforge.net/ +[OpenSSL]: http://www.openssl.org/ +[stunnel]: http://stunnel.mirt.net/ +[DB]: http://dustinbreese.blogspot.com/2008/09/stunnel.html + +[[!tag tags/linux]] +[[!tag tags/tools]] -- 2.26.2