How to Access the Desktop of a Firewalled Mac Using SSH

Problem

You have a remote Mac at home behind a router, or at work behind the company firewall, and you want to access its desktop from your local Mac. We will assume that screen sharing is enabled in the remote Mac. Of course you want to access the desktop securely [you don't want anyone else to record your session]. There are three possibilities.

Solution 1

You can't ssh between the local Mac and the remote Mac, but both Macs can ssh into a server:

On the local Mac, you will be prompted for a [remote Mac] username/password, enter them, and the remote Mac's desktop will appear.

Solution 2

You can ssh from the local Mac into the remote Mac:

On the local Mac, you will be prompted for a [remote Mac] username/password, enter them, and the remote Mac's desktop will appear.

Solution 3

You can ssh from the remote Mac into the local Mac:

On the local Mac, you will be prompted for a [remote Mac] username/password, enter them, and the remote Mac's desktop will appear.

Notes