#!/bin/sh # Fix file ownership with fakeroot so that OpenSSH will run as a user. # # The ownership is not really changed on disk, but 'chmod go-w' might actually # change permissions on disk. case "$LD_PRELOAD" in libfakeroot-sysv.so) ;; '') exec fakeroot -- "$0" "$@" ;; *) exit 1 ;; esac fixperms() { set -- "$1" local p="$1" oldp= while [ "$p" != "$oldp" ] do oldp=$p p=${p%/*}/ set -- "$@" "$p" done chown root:root "$@" chmod go-w "$@" } fixperms "$HOME"/.ssh PATH=/sbin:/usr/sbin:$PATH cmd="$(which sshd) $*" runuser -u "$USER" -- sh -c "$cmd"