summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2021-10-24 06:37:45 -0400
committerAndrew Cady <d@cryptonomic.net>2021-10-24 06:37:45 -0400
commitf58f4fdb3919c196a747636007af7da1ee308e28 (patch)
treef6db0c624fab483db801f38d3e28993b7c8c2dab
parent5e1f460dd3bf6288893ae61429a94dd90d19cdfb (diff)
Eliminate hard-coded values in sshd_config
This dirties up the code though, making the separate directory approach look better again. But it's not that bad.
-rw-r--r--EndoForge/Makefile16
-rw-r--r--EndoForge/src/sshd_config19
2 files changed, 26 insertions, 9 deletions
diff --git a/EndoForge/Makefile b/EndoForge/Makefile
index 3846ebd..b6bba95 100644
--- a/EndoForge/Makefile
+++ b/EndoForge/Makefile
@@ -1,8 +1,11 @@
1ENDOFORGE_BACKUPS = y 1ENDOFORGE_BACKUPS = y
2ifneq (,$(ENDOFORGE_BACKUPS)) 2ifneq (,$(ENDOFORGE_BACKUPS))
3INSTALL := install -b --suffix=~$(shell date -Ins | tr -d :) 3SUFFIX := ~$(shell date -Ins | tr -d :)
4INSTALL := install -b --suffix=$(SUFFIX)
5MV := mv -b --suffix=$(SUFFIX)
4else 6else
5INSTALL = install 7INSTALL = install
8MV = mv
6endif 9endif
7 10
8ifeq ($(shell id -u),0) 11ifeq ($(shell id -u),0)
@@ -32,12 +35,21 @@ SRC = src
32SOURCE_NAMES = AnonymousAccessCommand anonymous-access.conf AuthorizedKeysCommand sshd_config 35SOURCE_NAMES = AnonymousAccessCommand anonymous-access.conf AuthorizedKeysCommand sshd_config
33SOURCES = $(addprefix $(SRC), $(SOURCE_NAMES)) 36SOURCES = $(addprefix $(SRC), $(SOURCE_NAMES))
34 37
38KEYTYPE = ed25519
39define EDIT_SSHD
40sed \
41 -e 's?ForceCommand=$$?&$(HOME)/.ssh/AnonymousAccessCommand?' \
42 -e 's?AuthorizedKeysCommandUser=$$?&$(USER)?' \
43 -e 's?HostKey=$$?&$(HOME)/.ssh/id_$(KEYTYPE)?' \
44 -e 's?PidFile=$$?&$(HOME)/.ssh/sshd.pid?'
45endef
46
35install: install-user install-root 47install: install-user install-root
36 48
37install-user: 49install-user:
38 $(INSTALL) -d ~/.ssh 50 $(INSTALL) -d ~/.ssh
39 $(INSTALL) -t ~/.ssh $(SRC)/AnonymousAccessCommand 51 $(INSTALL) -t ~/.ssh $(SRC)/AnonymousAccessCommand
40 $(INSTALL) -m0600 -t ~/.ssh $(SRC)/sshd_config 52 $(EDIT_SSHD) < $(SRC)/sshd_config > ~/.ssh/sshd_config.tmp && $(MV) ~/.ssh/sshd_config.tmp ~/.ssh/sshd_config
41 53
42install-root: 54install-root:
43 $(ROOT_INSTALL) -d "$(SSH_CONFIG_DIR)" "$(SSHD_CONFIG_DIR)" "$(SSH_LIB_DIR)" || true 55 $(ROOT_INSTALL) -d "$(SSH_CONFIG_DIR)" "$(SSHD_CONFIG_DIR)" "$(SSH_LIB_DIR)" || true
diff --git a/EndoForge/src/sshd_config b/EndoForge/src/sshd_config
index de34cd4..f89a47d 100644
--- a/EndoForge/src/sshd_config
+++ b/EndoForge/src/sshd_config
@@ -1,15 +1,20 @@
1# This allows completely open access: 1# This is an sshd_config for running OpenSSH as an unprivileged user on a
2# non-standard port.
3Port=22022
4
5# This setting completely opens up access:
2AuthorizedKeysCommand=/bin/echo %t %k 6AuthorizedKeysCommand=/bin/echo %t %k
3# Only this closes it back up: 7
4ForceCommand=/home/u/.ssh/AnonymousAccessCommand 8# This closes it back up:
9ForceCommand=
10DisableForwarding=yes
5 11
6AuthenticationMethods publickey 12AuthenticationMethods publickey
7AuthorizedKeysCommandUser=u 13AuthorizedKeysCommandUser=
8ExposeAuthInfo=yes 14ExposeAuthInfo=yes
9 15
10Port=22022 16HostKey=
11HostKey=/home/u/.ssh/id_ed25519 17PidFile=
12PidFile=/home/u/.ssh/sshd.pid
13 18
14AcceptEnv LANG LC_* 19AcceptEnv LANG LC_*
15UsePAM no 20UsePAM no