Install openssh server on machine B.
$ sudo apt-get install openssh-server
In Ubuntu ssh server will be started automatically. If not start it
$ sudo /etc/init.d/sshd startNow you can connect to B from A
username will be user of system B.
When you do this for the first time , you may be asked to type yes/no to add the finger print of the remote machine. Now enter the password and you are done.
You can execute normal shell commands on machine B now.
$ssh -X firstname.lastname@example.org
will also allow you to take GUI control.
Try running gedit on the remote machine. The GUI will come on your local machine.