Search code examples
sshvncvnc-servervnc-viewer

send X11 window from local PC, with VNC over SSH to remote PC, without touching remote PC


Let's say I have two Linux PCs: LOCAL, where I sit physically, and REMOTE, that is connected to projector. So, while sitting at my LOCAL computer, I want launch a graphical application, let's say google-chrome, and I want that to show up on the remote computer - but I don't want to physically go to remote computer and start 'vncviewer' every time I want to do this. I don't even want to go there to log in. How can I solve this problem?

In other words, I DO NOT want to do this every time:

  1. Start x11vnc server on local pc:

    LOCAL_PC ~$ x11vnc
    # and do some graphical stuff, like: 
    LOCAL_PC ~$ firefox &
    
  2. and then, physically go to the remote computer and start the vnc client:

    REMOTE_PC ~$ vncviewer LOCAL_PC_IP
    

Solution

  • So i found the solution. (to make sure this is the thing you are looking for: this solution will help you to open graphical applications on your computer and display it on remote computers monitor)

    Short version

        REMOTE_PC ~$ xhost +localhost
        LOCAL_PC ~$ x11vnc -geometry 2560x1440 &
        LOCAL_PC ~$ ssh UserName@REMOTE_PC_IP "export DISPLAY=:0.0 xeyes && cinnamon-screensaver-command -d && vncviewer LOCAL_PC_IP"
    

    p.s. I don't know if the first line is even necessary

    Long version :

    REMOTE_PC -is the pc that is connected to projector

    LOCAL_PC -is the pc that you sit on.

    things to do on REMOTE_PC with IP - REMOTE_PC_IP

    to enable localhost x controlling. PHYSICALLY go and type that, u need to do it once.

        xhost +localhost
    

    things to do on LOCAL_PC with IP - LOCAL_PC_IP

    start vnc server

        x11vnc -geometry 2560x1440
    

    ssh to remote pc

        ssh username@REMOTE_PC_IP
    

    export display, unlock screen on that remote pc (like you entered password and logged in), start client and connect to server that was started on local PC.

        export DISPLAY=:0.0 xeyes
        cinnamon-screensaver-command -d
        vncviewer LOCAL_PC_IP
    

    p.s. instead of cinnamon-screensaver-command, you might need to use gnome-screensaver-command