Put torsocks in front of a command and its connections go through Tor:

torsocks curl https://check.torproject.org/api/ip
torsocks ssh [email protected]

It works by preloading a library (via LD_PRELOAD) that intercepts the program's networking calls and redirects them to Tor's SOCKS port. It also resolves hostnames through Tor and refuses UDP and other traffic Tor can't carry, rather than letting it slip out over your regular connection. That's the main advantage over just setting a proxy environment variable and hoping the app respects it.

There are limits. Statically linked programs and anything that makes raw system calls bypass the preload trick, which includes a lot of Go binaries. It doesn't work on Windows, and macOS's System Integrity Protection gets in the way for system binaries. And torsocks only hides your IP; it doesn't stop the program from sending identifying data.

For a whole system that can't leak even when a program misbehaves, Whonix or Tails is the stronger answer. proxychains is a similar tool with more options for chaining proxies.