Mac boxes make comparatively rotten IP routers. Awkward, potentially insecure, and difficult to manage. Get yourself a real IP router, preferably with VPN server capabilies, and remote operations and management will tend to get far easier. (There are both commercial and open-source options.)
As for your question, the easiest way is via VNC; open screen sharing, connect in, and off you go.
For the command line version, something akin to the following should get you where you want:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist
Google around for details of these commands and of the plist and alternatives, depending on your particular requirements. I've seen an AppleScript (somewhere) that tweaks this stuff, if you prefer that interface.