You can use something like systemd-inhibit to block sleep/suspend while you're running the command. This has the express benefit of being a dynamic solution, rather than masking the calls entirely.
systemd-inhibit --what=sleep --mode=block ssh
I use this to stop my machines from shutting down while my backups are running. Once the command completes, it ...