2023-08-10 16:16:53 +00:00
|
|
|
# $OpenBSD: forcecommand.sh,v 1.5 2023/05/12 06:36:27 djm 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
|
|
|
|
|
2015-07-02 13:15:34 +00: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-09-30 13:29:51 +00:00
|
|
|
|
2018-05-06 12:24:45 +00:00
|
|
|
trace "forced command in key option"
|
2023-08-10 16:16:53 +00:00
|
|
|
${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command in key option"
|
2006-09-30 13:29:51 +00:00
|
|
|
|
2015-07-02 13:15:34 +00: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-09-30 13:29:51 +00:00
|
|
|
|
|
|
|
cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
|
|
|
|
echo "ForceCommand true" >> $OBJ/sshd_proxy
|
|
|
|
|
2018-05-06 12:24:45 +00:00
|
|
|
trace "forced command in sshd_config overrides key option"
|
2023-08-10 16:16:53 +00:00
|
|
|
${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command config"
|
2006-09-30 13:29:51 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-05-06 12:24:45 +00:00
|
|
|
trace "forced command with match"
|
2023-08-10 16:16:53 +00:00
|
|
|
${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command match"
|