Assuming your GUI is X-based (as almost all UNIX GUIs are), use xinput
.
First, list your devices:
$ xinput --list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Windows mouse id=6 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Windows keyboard id=7 [slave keyboard (3)]
List the details for your mouse (id=6 in our example):
$ xinput --list-props 6
Device 'Windows mouse':
Device Enabled (112): 1
Coordinate Transformation Matrix (114): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (222): 0
Device Accel Constant Deceleration (223): 1.000000
Device Accel Adaptive Deceleration (224): 1.000000
Device Accel Velocity Scaling (225): 10.000000
Now disable it:
$ export DISPLAY=:0
$ xinput set-int-prop 6 "Device Enabled" 8 0
To enable it do:
$ xinput set-int-prop 6 "Device Enabled" 8 1
The same goes for the keyboard, just replace the int-prop number with the proper id.
Tested and worked on cygwin.
Of course, you have to plan beforehand how will you enable your devices again. such as schedule it on cron, re-enable it remotely, or disable just one of them in first place.