| 1 |
# Remote accountd server process |
| 2 |
|
| 3 |
adduser --disabled-password --shell /bin/sh \ |
| 4 |
--home /home/lacme-account \ |
| 5 |
--gecos "lacme account user" \ |
| 6 |
--quiet lacme-account |
| 7 |
|
| 8 |
chown lacme-account: /etc/lacme/account.key |
| 9 |
|
| 10 |
DEBIAN_FRONTEND="noninteractive" apt install -y --no-install-recommends \ |
| 11 |
openssh-client openssh-server |
| 12 |
ssh-keygen -N "" -f ~root/.ssh/id_rsa |
| 13 |
|
| 14 |
install -olacme-account -glacme-account -dm0700 ~lacme-account/.ssh |
| 15 |
install -olacme-account -glacme-account -m0644 ~root/.ssh/id_rsa.pub ~lacme-account/.ssh/authorized_keys |
| 16 |
{ echo -n "[127.0.0.1]:2222 "; cat /etc/ssh/ssh_host_rsa_key.pub; } >~root/.ssh/known_hosts |
| 17 |
|
| 18 |
cat >/etc/ssh/sshd_config <<-EOF |
| 19 |
Port 2222 |
| 20 |
ListenAddress 127.0.0.1 |
| 21 |
ChallengeResponseAuthentication no |
| 22 |
PasswordAuthentication no |
| 23 |
UsePAM yes |
| 24 |
EOF |
| 25 |
install -oroot -groot -dm0755 /run/sshd |
| 26 |
/usr/sbin/sshd |
| 27 |
|
| 28 |
sed -ri 's|^#?command\s*=.*/lacme-accountd$|command = ssh -Tp2222 -llacme-account 127.0.0.1 lacme-accountd|' /etc/lacme/lacme.conf |
| 29 |
sed -ri 's|^#?config\s*=.*|config = /etc/lacme/lacme-accountd.conf|' /etc/lacme/lacme.conf |
| 30 |
lacme newOrder --debug 2>"$STDERR" || fail # intentionally use --debug, ssh should tunnel stdin + stdout + stderr |
| 31 |
test /etc/lacme/simpletest.rsa.crt -nt /etc/lacme/simpletest.rsa.key |
| 32 |
|
| 33 |
# and now with an authorized_keys(5) restriction |
| 34 |
sed -ri "s|^[^#]|restrict,from=\"127.0.0.1\",command=\"/usr/bin/lacme-accountd --quiet --stdio\" &|" ~lacme-account/.ssh/authorized_keys |
| 35 |
rm -vf /etc/lacme/simpletest.rsa.crt |
| 36 |
|
| 37 |
! lacme newOrder 2>"$STDERR" || fail # --config= (and --debug) should be ignored |
| 38 |
grepstderr -Fxq "Error: 'privkey' is not specified" |
| 39 |
grepstderr -Fxq "[simpletest-rsa] Error: Couldn't issue X.509 certificate!" |
| 40 |
|
| 41 |
install -olacme-account -glacme-account -Ddm0700 -- \ |
| 42 |
~lacme-account/.config/lacme ~lacme-account/.local/share/lacme |
| 43 |
mv -t ~lacme-account/.config/lacme /etc/lacme/account.key |
| 44 |
cat >~lacme-account/.config/lacme/lacme-accountd.conf <<-EOF |
| 45 |
privkey = file:%E/lacme/account.key |
| 46 |
logfile = %h/.local/share/lacme/accountd.log |
| 47 |
EOF |
| 48 |
|
| 49 |
lacme newOrder |
| 50 |
test /etc/lacme/simpletest.rsa.crt -nt /etc/lacme/simpletest.rsa.key |
| 51 |
|
| 52 |
# ensure signature requests are logged |
| 53 |
grep -F "] SIGNED header=base64url({" ~lacme-account/.local/share/lacme/accountd.log |
| 54 |
|
| 55 |
# vim: set filetype=sh : |