1# $OpenBSD: forcecommand.sh,v 1.2 2013/05/17 00:37:40 dtucker Exp $ 2# Placed in the Public Domain. 3 4tid="forced command" 5 6cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak 7 8printf 'command="true" ' >$OBJ/authorized_keys_$USER 9cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER 10printf 'command="true" ' >>$OBJ/authorized_keys_$USER 11cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER 12 13for p in 1 2; do 14 trace "forced command in key option proto $p" 15 ${SSH} -$p -F $OBJ/ssh_proxy somehost false \ || 16 fail "forced command in key proto $p" 17done 18 19printf 'command="false" ' >$OBJ/authorized_keys_$USER 20cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER 21printf 'command="false" ' >>$OBJ/authorized_keys_$USER 22cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER 23 24cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy 25echo "ForceCommand true" >> $OBJ/sshd_proxy 26 27for p in 1 2; do 28 trace "forced command in sshd_config overrides key option proto $p" 29 ${SSH} -$p -F $OBJ/ssh_proxy somehost false \ || 30 fail "forced command in key proto $p" 31done 32 33cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy 34echo "ForceCommand false" >> $OBJ/sshd_proxy 35echo "Match User $USER" >> $OBJ/sshd_proxy 36echo " ForceCommand true" >> $OBJ/sshd_proxy 37 38for p in 1 2; do 39 trace "forced command with match proto $p" 40 ${SSH} -$p -F $OBJ/ssh_proxy somehost false \ || 41 fail "forced command in key proto $p" 42done 43