summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2021-10-24 06:15:10 -0400
committerAndrew Cady <d@cryptonomic.net>2021-10-24 06:18:45 -0400
commit5e1f460dd3bf6288893ae61429a94dd90d19cdfb (patch)
treec0811cf81cbdcad19d0f7bd84b26350ad3835310
parent187db8e649641aa64dc49c29ea6bbeba1f7cabf7 (diff)
Removing run-sshd script
I realized that if you are running `sshd` as a user, then you can just use `ForceCommand=` directly in the `sshd_config`. This eliminates the need for fakeroot. And that simplifies the setup enough so that the `openssh/` directory can go away.
-rw-r--r--EndoForge/Makefile33
-rw-r--r--EndoForge/README.md15
-rwxr-xr-xEndoForge/openssh/AuthorizedKeysCommand21
-rw-r--r--EndoForge/openssh/Makefile7
-rwxr-xr-xEndoForge/openssh/run-sshd32
-rw-r--r--EndoForge/src/sshd_config (renamed from EndoForge/openssh/sshd_config)16
6 files changed, 42 insertions, 82 deletions
diff --git a/EndoForge/Makefile b/EndoForge/Makefile
index 46f1af4..3846ebd 100644
--- a/EndoForge/Makefile
+++ b/EndoForge/Makefile
@@ -1,13 +1,18 @@
1ENDOFORGE_BACKUPS = y
2ifneq (,$(ENDOFORGE_BACKUPS))
3INSTALL := install -b --suffix=~$(shell date -Ins | tr -d :)
4else
5INSTALL = install
6endif
7
1ifeq ($(shell id -u),0) 8ifeq ($(shell id -u),0)
2SUDO = 9SUDO =
3else 10else
4SUDO = sudo 11SUDO = sudo
5endif 12endif
6 13
7ROOT_INSTALL = $(SUDO) install 14ROOT_INSTALL = $(SUDO) $(INSTALL)
8
9USER != echo "$${SUDO_USER:-$$(id -un)}" 15USER != echo "$${SUDO_USER:-$$(id -un)}"
10
11SSH_CONFIG_DIR = /etc/ssh 16SSH_CONFIG_DIR = /etc/ssh
12SSHD_CONFIG_DIR = $(SSH_CONFIG_DIR)/sshd_config.d 17SSHD_CONFIG_DIR = $(SSH_CONFIG_DIR)/sshd_config.d
13SSH_LIB_DIR = /usr/lib/ssh 18SSH_LIB_DIR = /usr/lib/ssh
@@ -15,7 +20,7 @@ USER_SSH_CONFIG_DIR = ~$(USER)/.ssh
15 20
16BROWSER != 2>/dev/null which xdg-open || which w3m || which links || which elinks 21BROWSER != 2>/dev/null which xdg-open || which w3m || which links || which elinks
17 22
18.PHONY: install shared doc test 23.PHONY: install install-user install-root shared doc test
19 24
20doc: README.html 25doc: README.html
21 $(BROWSER) $< 26 $(BROWSER) $<
@@ -24,17 +29,27 @@ shared: install
24 git config core.self-forge true 29 git config core.self-forge true
25 30
26SRC = src 31SRC = src
27SOURCES = $(addprefix $(SRC), AnonymousAccessCommand anonymous-access.conf AuthorizedKeysCommand) 32SOURCE_NAMES = AnonymousAccessCommand anonymous-access.conf AuthorizedKeysCommand sshd_config
33SOURCES = $(addprefix $(SRC), $(SOURCE_NAMES))
34
35install: install-user install-root
28 36
29install: 37install-user:
30 install -t $(USER_SSH_CONFIG_DIR) $(SRC)/AnonymousAccessCommand 38 $(INSTALL) -d ~/.ssh
31 $(ROOT_INSTALL) -d "$(SSH_CONFIG_DIR)" "$(SSHD_CONFIG_DIR)" "$(SSH_LIB_DIR)" || true 39 $(INSTALL) -t ~/.ssh $(SRC)/AnonymousAccessCommand
40 $(INSTALL) -m0600 -t ~/.ssh $(SRC)/sshd_config
41
42install-root:
43 $(ROOT_INSTALL) -d "$(SSH_CONFIG_DIR)" "$(SSHD_CONFIG_DIR)" "$(SSH_LIB_DIR)" || true
32 $(ROOT_INSTALL) -m0644 -t "$(SSHD_CONFIG_DIR)" $(SRC)/anonymous-access.conf || true 44 $(ROOT_INSTALL) -m0644 -t "$(SSHD_CONFIG_DIR)" $(SRC)/anonymous-access.conf || true
33 $(ROOT_INSTALL) -t "$(SSH_LIB_DIR)" $(SRC)/AuthorizedKeysCommand || true 45 $(ROOT_INSTALL) -t "$(SSH_LIB_DIR)" $(SRC)/AuthorizedKeysCommand || true
34 [ -e "$(SSH_LIB_DIR)"/AuthorizedKeysCommand ] || $(SUDO) ln -s -t /etc/ssh "$(SSH_LIB_DIR)"/AuthorizedKeysCommand 46 [ -e "$(SSH_LIB_DIR)"/AuthorizedKeysCommand ] || $(SUDO) ln -s -t /etc/ssh "$(SSH_LIB_DIR)"/AuthorizedKeysCommand
35 47
48run: install-user
49 /usr/sbin/sshd -D -e -f ~/.ssh/sshd_config
50
36README.html: README.md 51README.html: README.md
37 pandoc -s --css style.css -t html $< -o $@ 52 pandoc --metadata 'EndoForge - A self-forge in any git repository' -s --css style.css -t html $< -o $@
38 53
39test: 54test:
40 make -C test 55 make -C test
diff --git a/EndoForge/README.md b/EndoForge/README.md
index 0b1a8dd..14e640e 100644
--- a/EndoForge/README.md
+++ b/EndoForge/README.md
@@ -1,6 +1,8 @@
1EndoForge 1EndoForge
2--------- 2---------
3Convert your Git repository into a Self-Forge by merging this repository. 3A Self-Forge.
4
5Convert any Git repository into a Self-Forge by merging this repository.
4 6
5 7
6 8
@@ -57,8 +59,8 @@ Run:
57 make install 59 make install
58``` 60```
59 61
60This installs the `AnonymousAccessCommand` in the current user's home 62This installs the `AnonymousAccessCommand` in the current user's home directory
61directory. 63(under `$HOME/.ssh`).
62 64
63Then, if sudo access is available, it enables anonymous access by 65Then, if sudo access is available, it enables anonymous access by
64editing the system `OpenSSH` configuration. 66editing the system `OpenSSH` configuration.
@@ -71,8 +73,8 @@ editing the system `OpenSSH` configuration.
71NON-ROOT INSTALLATION 73NON-ROOT INSTALLATION
72--------------------- 74---------------------
73 75
74A configuration is included for running OpenSSH from an unprivileged user 76An OpenSSH configuration and wrapper is included for running EndoForge from an
75account. Try it like so: 77unprivileged user account. Try it like so:
76 78
77 79
78``` 80```
@@ -83,7 +85,8 @@ account. Try it like so:
83``` 85```
84 86
85This launches a script that uses 'fakeroot' and to make OpenSSH think the 87This launches a script that uses 'fakeroot' and to make OpenSSH think the
86permissions are OK. 88permissions are OK. This repository needs a systemd service file to launch it
89automatically (TODO).
87 90
88 91
89 92
diff --git a/EndoForge/openssh/AuthorizedKeysCommand b/EndoForge/openssh/AuthorizedKeysCommand
deleted file mode 100755
index 0e6d285..0000000
--- a/EndoForge/openssh/AuthorizedKeysCommand
+++ /dev/null
@@ -1,21 +0,0 @@
1#!/bin/sh
2# Modified AuthorizedKeysCommand for running OpenSSH as unprivileged user.
3#
4# Uses the home directory of the calling user (ascertained through "id -un")
5# instead of the authenticated user.
6
7fingerprint=$3
8authline="$4 $5"
9
10username=$(id -un)
11userhome=$(getent passwd $(id -un) | (IFS=: read _ _ _ _ _ home _ && echo "$home"))
12
13case "$userhome" in
14 '' | *"'"* ) exit ;;
15esac
16
17usercommand=$userhome/.ssh/AnonymousAccessCommand
18
19[ -x "$usercommand" ] || exit
20
21printf 'command="%s",no-port-forwarding %s\n' "$usercommand $fingerprint" "$authline"
diff --git a/EndoForge/openssh/Makefile b/EndoForge/openssh/Makefile
deleted file mode 100644
index ae39ed2..0000000
--- a/EndoForge/openssh/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
1
2run:
3 ./run-sshd -D -e -f ~/.ssh/sshd_config
4
5install:
6 install -m0600 sshd_config -t ~/.ssh
7 install -m0755 AuthorizedKeysCommand -t ~/.ssh
diff --git a/EndoForge/openssh/run-sshd b/EndoForge/openssh/run-sshd
deleted file mode 100755
index 20e82d8..0000000
--- a/EndoForge/openssh/run-sshd
+++ /dev/null
@@ -1,32 +0,0 @@
1#!/bin/sh
2# Fix file ownership with fakeroot so that OpenSSH will run as a user.
3#
4# The ownership is not really changed on disk, but 'chmod go-w' might actually
5# change permissions on disk.
6
7case "$LD_PRELOAD" in
8 libfakeroot-sysv.so) ;;
9 '') exec fakeroot -- "$0" "$@" ;;
10 *) exit 1 ;;
11esac
12
13fixperms()
14{
15 set -- "$1"
16 local p="$1" oldp=
17 while [ "$p" != "$oldp" ]
18 do
19 oldp=$p
20 p=${p%/*}/
21 set -- "$@" "$p"
22 done
23 chown root:root "$@"
24 chmod go-w "$@"
25}
26
27fixperms "$HOME"/.ssh
28
29PATH=/sbin:/usr/sbin:$PATH
30cmd="$(which sshd) $*"
31runuser -u "$USER" -- sh -c "$cmd"
32
diff --git a/EndoForge/openssh/sshd_config b/EndoForge/src/sshd_config
index 2273805..de34cd4 100644
--- a/EndoForge/openssh/sshd_config
+++ b/EndoForge/src/sshd_config
@@ -1,15 +1,17 @@
1Port=22022 1# This allows completely open access:
2 2AuthorizedKeysCommand=/bin/echo %t %k
3HostKey=/home/u/.ssh/id_ed25519 3# Only this closes it back up:
4PidFile=/home/u/.ssh/sshd.pid 4ForceCommand=/home/u/.ssh/AnonymousAccessCommand
5 5
6AuthenticationMethods publickey
6AuthorizedKeysCommandUser=u 7AuthorizedKeysCommandUser=u
7AuthorizedKeysCommand=/home/u/.ssh/AuthorizedKeysCommand %u %h %f "%t %k"
8ExposeAuthInfo=yes 8ExposeAuthInfo=yes
9 9
10AuthenticationMethods publickey 10Port=22022
11HostKey=/home/u/.ssh/id_ed25519
12PidFile=/home/u/.ssh/sshd.pid
13
11AcceptEnv LANG LC_* 14AcceptEnv LANG LC_*
12Subsystem sftp /usr/lib/openssh/sftp-server
13UsePAM no 15UsePAM no
14PermitTTY no 16PermitTTY no
15ChrootDirectory=none 17ChrootDirectory=none