I just saw an option in Fortinet NGFW regarding,
SSH Deep Inspection. So my question is how Deep inspection or whatever can inspect or find any malicious activity on encrypted packets?
I'm not familiar exactly with what Fortinet offers and how they've implemented it. But in general SSH deep inspection is similar to SSL deep inspection: it does a man in the middle "attack" where the endpoint trusts the certificate or key provided by the inspection appliance. Same as in SSL inspection the original server key can not be used with the client (since the matching private key is only known to the server) but a fixed or dynamically generated key will be used instead. With SSL it is usually enough to add trust for the proxy CA to all clients in order to accept all generated certificates. But since SSH is commonly used without certificates and without PKI one needs to trust each server key directly. This is true SSH with and without SSH inspection, but with SSH inspection you cannot any longer use the original servers fingerprint to check if you got the correct key.
As for what you can do with such deep inspection: Looking at Fortinet: SSL/SSH inspection it seems to be that they support allowing or blocking shell access, executing programs, using X11 and using port forwarding through SSH. Other firewalls can also restrict access to subsystems (i.e. block sftp) or provide a more granular policy for which commands can be executed over SSH and which not.