You can use x11vnc to make a virtual screen and connect to it from the second machine through a vnc client. For extended desktop, you can use a dummy male VGA or HDMI (I used the ones of a broken monitor not plugged to the electrical network) connected to your main computer and add a "virtual screen" with xrandr.
- From terminal, run:
xrand
and take note of one of the disconnected devices that appear in the output, i.e. "DP-2" or "HDMI-2".
- Generate the modeline for the resolution to beam in the monitor of second machine, i.e. for my smartphone: 1200x540 at 120 Mhz. Run in terminal:
gtf 1200 540 120
- Make a new resolution mode based on the notes taken in the first step. In terminal, run:
xrandr --newmode "1200x540_120.00" 112.28 1200 1280 1408 1616 540 541 544 579 -HSync +Vsync
- Add the created mode as an output option to a dummy that will be plugged into a port not used in the main machine, in my case "DP-2". Run:
xrandr --addmode DP-2 1200x540_120.00
- Plug the dummy and set the output to extend the desktop, run:
xrandr --output DP-2 --mode 1200x540_120.00 --right-of eDP-1
.
- Run:
x11vnc -localhost -usepw -forever -bg -geometry 1200x540 -shared -noprimary -auth /var/run/lightdm/root/:0 -display :0 -clip 1200x540+3520+450 -threads -noxdamage -noxwarppointer
(remember that the device names and resolution values are just for my case).
- Run any vnc client in the second machine for connect to main machine.
The steps were taken from a post in my old blog (spanish).
Also, you can use Deskreen.