freebsd-dev/regress/forcecommand.sh

43 lines
1.3 KiB
Bash
Raw Normal View History

2013-09-18 17:27:38 +00:00
# $OpenBSD: forcecommand.sh,v 1.2 2013/05/17 00:37:40 dtucker Exp $
2006-09-30 13:29:51 +00:00
# Placed in the Public Domain.
tid="forced command"
cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
2013-09-18 17:27:38 +00:00
printf 'command="true" ' >$OBJ/authorized_keys_$USER
2006-09-30 13:29:51 +00:00
cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER
2013-09-18 17:27:38 +00:00
printf 'command="true" ' >>$OBJ/authorized_keys_$USER
2006-09-30 13:29:51 +00:00
cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER
for p in 1 2; do
trace "forced command in key option proto $p"
${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
fail "forced command in key proto $p"
done
2013-09-18 17:27:38 +00:00
printf 'command="false" ' >$OBJ/authorized_keys_$USER
2006-09-30 13:29:51 +00:00
cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER
2013-09-18 17:27:38 +00:00
printf 'command="false" ' >>$OBJ/authorized_keys_$USER
2006-09-30 13:29:51 +00:00
cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER
cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
echo "ForceCommand true" >> $OBJ/sshd_proxy
for p in 1 2; do
trace "forced command in sshd_config overrides key option proto $p"
${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
fail "forced command in key proto $p"
done
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
for p in 1 2; do
trace "forced command with match proto $p"
${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
fail "forced command in key proto $p"
done