forcecommand.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # $OpenBSD: forcecommand.sh,v 1.4 2017/04/30 23:34:55 djm Exp $
  2. # Placed in the Public Domain.
  3. tid="forced command"
  4. cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
  5. cp /dev/null $OBJ/authorized_keys_$USER
  6. for t in ${SSH_KEYTYPES}; do
  7. printf 'command="true" ' >> $OBJ/authorized_keys_$USER
  8. cat $OBJ/$t.pub >> $OBJ/authorized_keys_$USER
  9. done
  10. trace "forced command in key option"
  11. ${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command in key"
  12. cp /dev/null $OBJ/authorized_keys_$USER
  13. for t in ${SSH_KEYTYPES}; do
  14. printf 'command="false" ' >> $OBJ/authorized_keys_$USER
  15. cat $OBJ/$t.pub >> $OBJ/authorized_keys_$USER
  16. done
  17. cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
  18. echo "ForceCommand true" >> $OBJ/sshd_proxy
  19. trace "forced command in sshd_config overrides key option"
  20. ${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command in key"
  21. cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy
  22. echo "ForceCommand false" >> $OBJ/sshd_proxy
  23. echo "Match User $USER" >> $OBJ/sshd_proxy
  24. echo " ForceCommand true" >> $OBJ/sshd_proxy
  25. trace "forced command with match"
  26. ${SSH} -F $OBJ/ssh_proxy somehost false || fail "forced command in key"