Confession time: I don’t fully understand how terminals, shells and SSH really work (and my guess is you don’t either). And I don’t mean the cryptography behind SSH. I mean how SSH and the terminal — and the shell for that matter — interact with one another.
I mean, it’s one of those things I kind of understand, but not completely. The author of the short linked post found four articles that detail all this stuff quite well, so go on over there and see just how well you really understood it.