2015-03-03 23:35:19 +01:00
|
|
|
# $OpenBSD: forcecommand.sh,v 1.3 2015/03/03 22:35:19 markus Exp $
|
2006-07-24 07:31:41 +02:00
|
|
|
# Placed in the Public Domain.
|
|
|
|
|
|
|
|
tid="forced command"
|
|
|
|
|
|
|
|
cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
|
|
|
|
|
2015-03-03 23:35:19 +01:00
|
|
|
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
|
2006-07-24 07:31:41 +02:00
|
|
|
|
2015-03-03 23:35:19 +01:00
|
|
|
for p in ${SSH_PROTOCOLS}; do
|
2006-07-24 07:31:41 +02:00
|
|
|
trace "forced command in key option proto $p"
|
|
|
|
${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
|
|
|
|
fail "forced command in key proto $p"
|
|
|
|
done
|
|
|
|
|
2015-03-03 23:35:19 +01:00
|
|
|
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
|
2006-07-24 07:31:41 +02:00
|
|
|
|
|
|
|
cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
|
|
|
|
echo "ForceCommand true" >> $OBJ/sshd_proxy
|
|
|
|
|
2015-03-03 23:35:19 +01:00
|
|
|
for p in ${SSH_PROTOCOLS}; do
|
2006-07-24 07:31:41 +02:00
|
|
|
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
|
|
|
|
|
2015-03-03 23:35:19 +01:00
|
|
|
for p in ${SSH_PROTOCOLS}; do
|
2006-07-24 07:31:41 +02:00
|
|
|
trace "forced command with match proto $p"
|
|
|
|
${SSH} -$p -F $OBJ/ssh_proxy somehost false \ ||
|
|
|
|
fail "forced command in key proto $p"
|
|
|
|
done
|