summaryrefslogtreecommitdiffstats
path: root/debian/tests/socket-activation
blob: 20a0d0b06954c174f8fdde0de591d6e2d406d4df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /bin/sh
set -e

testuser="testuser$$"
adduser --quiet --disabled-password --gecos "" "$testuser"
sudo -u "$testuser" mkdir -m700 "/home/$testuser/.ssh"
sudo -u "$testuser" \
	ssh-keygen -t ed25519 -N '' -f "/home/$testuser/.ssh/id_ed25519"
sudo -u "$testuser" \
	cp "/home/$testuser/.ssh/id_ed25519.pub" \
	"/home/$testuser/.ssh/authorized_keys"

cleanup () {
	if [ $? -ne 0 ]; then
		echo "## Something failed"
		echo
		echo "## ssh server log"
		journalctl -b -u ssh.service --lines 100
	fi
}

trap cleanup EXIT

systemctl disable --now ssh.service
systemctl enable --now ssh.socket
sudo -u "$testuser" \
	ssh -oStrictHostKeyChecking=accept-new "$testuser@localhost" date