2 # SPDX-License-Identifier: LGPL-2.1-or-later
6 if ! command -v ssh &> /dev
/null ||
! command -v sshd
&> /dev
/null
; then
7 echo "ssh/sshd not found, skipping test." >&2
11 systemctl
-q is-active sshd-unix-local.socket
13 if test -e /dev
/vsock
; then
14 systemctl
-q is-active sshd-vsock.socket
17 if test -d /run
/host
/unix-export
; then
18 systemctl
-q is-active sshd-unix-export.socket
21 # FIXME: sshd seems to crash inside asan currently, skip the actual ssh test hence
22 if [[ -v ASAN_OPTIONS
]] ; then
29 rm -f "$ROOTID" "$ROOTID".pub
32 ssh-keygen
-N '' -C '' -t rsa
-f "$ROOTID"
34 mkdir
-p 0700 /root
/.
ssh
35 # Add a newline in case authorized_keys wasn't terminated correctly.
36 echo >>/root
/.ssh
/authorized_keys
37 cat "$ROOTID".pub
>>/root
/.ssh
/authorized_keys
39 # set root pw to "foo", just to set it to something valid
40 # shellcheck disable=SC2016
41 usermod
-p '$5$AAy6BYJ6rzz.QELv$6LpVEU3/RQmVz.svHu/33qoJWWWzZuJ3DM2fo9JgcUD' root
45 test -f /etc
/ssh
/ssh_host_rsa_key || ssh-keygen
-t rsa
-C '' -N '' -f /etc
/ssh
/ssh_host_rsa_key
46 echo "PermitRootLogin yes" >> /etc
/ssh
/sshd_config
47 echo "LogLevel DEBUG3" >> /etc
/ssh
/sshd_config
49 test -f /etc
/ssh
/ssh_config ||
{
50 echo 'Include /etc/ssh/ssh_config.d/*.conf'
51 echo 'Include /usr/etc/ssh/ssh_config.d/*.conf'
52 } >/etc
/ssh
/ssh_config
54 # ssh wants this dir around, but distros cannot agree on a common name for it, let's just create all that are aware of distros use
55 mkdir
-p /usr
/share
/empty.sshd
/var
/empty
/var
/empty
/sshd
/run
/sshd
57 ssh -o StrictHostKeyChecking
=no
-v -i "$ROOTID" .
host cat /etc
/machine-id |
cmp - /etc
/machine-id
58 ssh -o StrictHostKeyChecking
=no
-v -i "$ROOTID" unix
/run
/ssh-unix-local
/socket
cat /etc
/machine-id |
cmp - /etc
/machine-id
59 ssh -o StrictHostKeyChecking
=no
-v -i "$ROOTID" machine
/.
host cat /etc
/machine-id |
cmp - /etc
/machine-id
61 modprobe vsock_loopback ||
:
62 if test -e /dev
/vsock
-a -d /sys
/module
/vsock_loopback
; then
63 ssh -o StrictHostKeyChecking
=no
-v -i "$ROOTID" vsock
/1 cat /etc
/machine-id |
cmp - /etc
/machine-id