forcecommand.sh revision 255774
1145519Sdarrenr#	$OpenBSD: forcecommand.sh,v 1.2 2013/05/17 00:37:40 dtucker Exp $
2145510Sdarrenr#	Placed in the Public Domain.
3145510Sdarrenr
4145510Sdarrenrtid="forced command"
5145510Sdarrenr
6145510Sdarrenrcp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
7145510Sdarrenr
8145510Sdarrenrprintf 'command="true" ' >$OBJ/authorized_keys_$USER
9145510Sdarrenrcat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER
10145510Sdarrenrprintf 'command="true" ' >>$OBJ/authorized_keys_$USER
11145510Sdarrenrcat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER
12145510Sdarrenr
13145510Sdarrenrfor p in 1 2; do
14145510Sdarrenr	trace "forced command in key option proto $p"
15145510Sdarrenr	${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
16145510Sdarrenr	    fail "forced command in key proto $p"
17145510Sdarrenrdone
18145510Sdarrenr
19145510Sdarrenrprintf 'command="false" ' >$OBJ/authorized_keys_$USER
20145510Sdarrenrcat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER
21145510Sdarrenrprintf 'command="false" ' >>$OBJ/authorized_keys_$USER
22145510Sdarrenrcat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER
23145510Sdarrenr
24145510Sdarrenrcp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
25145510Sdarrenrecho "ForceCommand true" >> $OBJ/sshd_proxy
26145510Sdarrenr
27145510Sdarrenrfor p in 1 2; do
28145510Sdarrenr	trace "forced command in sshd_config overrides key option proto $p"
29145510Sdarrenr	${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
30145510Sdarrenr	    fail "forced command in key proto $p"
31145510Sdarrenrdone
32145510Sdarrenr
33145510Sdarrenrcp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
34145510Sdarrenrecho "ForceCommand false" >> $OBJ/sshd_proxy
35145510Sdarrenrecho "Match User $USER" >> $OBJ/sshd_proxy
36145510Sdarrenrecho "    ForceCommand true" >> $OBJ/sshd_proxy
37145510Sdarrenr
38145510Sdarrenrfor p in 1 2; do
39145510Sdarrenr	trace "forced command with match proto $p"
40145510Sdarrenr	${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
41145510Sdarrenr	    fail "forced command in key proto $p"
42145510Sdarrenrdone
43145510Sdarrenr