From bb7dda781458d8c823076c830c3be63d50aa2d46 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Mon, 30 Nov 2015 16:15:01 +0200
Subject: [PATCH] sshd test case now works reliably\!

---
 .gitignore  |  3 ++-
 Makefile    | 18 ++++++++++++++----
 sshd_config | 14 --------------
 3 files changed, 16 insertions(+), 19 deletions(-)
 delete mode 100644 sshd_config

diff --git a/.gitignore b/.gitignore
index 1605632..14a9a04 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,5 +5,6 @@
 CA*
 users/
 hosts/
-.server.pid
+sshd.pid
 known_hosts
+sshd_config
diff --git a/Makefile b/Makefile
index f9d4d6a..747e38d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,26 @@
 .PHONY: install clean test
 
+
+sshd_config:
+	@echo "ListenAddress 127.0.0.1:22222" > sshd_config
+	@echo "HostKey $$PWD/hosts/localhost" >> sshd_config
+	@echo "TrustedUserCAKeys $$PWD/CA.pub" >> sshd_config
+	@echo "HostCertificate $$PWD/hosts/localhost-cert.pub" >> sshd_config
+	@echo "PidFile sshd.pid" >> sshd_config
+	@echo "UsePrivilegeSeparation no" >> sshd_config
+
 install:
 	cp ssl-ca /usr/local/bin/ssh-ca
 	chmod 755 /usr/local/bin/ssh-ca
 
 clean:
-	rm -rf CA CA.pub users hosts known_hosts
+	rm -rf CA CA.pub users hosts known_hosts sshd.pid sshd_config
 
-test: clean
+test: clean sshd_config
 	./ssh-ca init
 	./ssh-ca newuser $$USER
 	./ssh-ca newhost localhost
 	echo "@cert-authority * $$(cat CA.pub)" > known_hosts
-	$$(which sshd) -dddf sshd_config
-	#ssh -F ssh_config test
+	$$(which sshd) -f sshd_config
+	test "$$(ssh -F ssh_config test whoami)" = "$$USER"
+	kill $$(cat sshd.pid)
diff --git a/sshd_config b/sshd_config
deleted file mode 100644
index b9d5198..0000000
--- a/sshd_config
+++ /dev/null
@@ -1,14 +0,0 @@
-ListenAddress 127.0.0.1:22222
-HostKey hosts/localhost
-TrustedUserCAKeys ssh_ca.pub
-HostCertificate hosts/localhost-cert.pub
-Banner "ssh-ca dummy test daemon"
-PasswordAuthentication no
-PermitRootLogin no
-PidFile .server.pid
-StrictModes no
-UsePrivilegeSeparation no
-UsePAM no
-RSAAuthentication yes
-PubkeyAuthentication yes
-Protocol 2
-- 
GitLab