Ssh commands restrict python usage
I am using a python script to restrict the use of commands with an argument command
in a file authorized_keys
.
command :
ssh host-name bash --login -c 'exec $0 "$@"' mkdir -p hello
My script takes the necessary steps to restrict commands. After filtering, the python script executes sys.exit(1)
for error and sys.exit(0)
for success. After the return value, the above ssh command will fail at the end. Is there something else I need to send from the python script to the SSH daemon?
source to share
The modifier command
in is authorized_keys
not used (only) to test the users command, but this command is executed instead of the command supplied by the user. This means that calling sys.exit(0)
from there prevents the user supplied command from being executed.
In this script, after checking this command, you need to run it too!
source to share