1
0
mirror of git://anongit.mindrot.org/openssh.git synced 2024-12-29 05:32:07 +00:00
openssh/regress/forcecommand.sh
djm@openbsd.org e43f43d3f1
upstream: better error messages
OpenBSD-Regress-ID: 55e4186604e80259496d841e690ea2090981bc7a
2023-07-30 11:17:43 +10:00

36 lines
1.1 KiB
Bash

# $OpenBSD: forcecommand.sh,v 1.5 2023/05/12 06:36:27 djm Exp $
# Placed in the Public Domain.
tid="forced command"
cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
cp /dev/null $OBJ/authorized_keys_$USER
for t in ${SSH_KEYTYPES}; do
printf 'command="true" ' >>$OBJ/authorized_keys_$USER
cat $OBJ/$t.pub >> $OBJ/authorized_keys_$USER
done
trace "forced command in key option"
${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command in key option"
cp /dev/null $OBJ/authorized_keys_$USER
for t in ${SSH_KEYTYPES}; do
printf 'command="false" ' >> $OBJ/authorized_keys_$USER
cat $OBJ/$t.pub >> $OBJ/authorized_keys_$USER
done
cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
echo "ForceCommand true" >> $OBJ/sshd_proxy
trace "forced command in sshd_config overrides key option"
${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command config"
cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
echo "ForceCommand false" >> $OBJ/sshd_proxy
echo "Match User $USER" >> $OBJ/sshd_proxy
echo " ForceCommand true" >> $OBJ/sshd_proxy
trace "forced command with match"
${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command match"