Tag: vnc

  • Install Xfce VNC remote desktop on CentOS 7

    Install Xfce VNC remote desktop on CentOS 7

    Xfce is a lightweight linux desktop environment. You can install Xfce on a remote server or virtual machine, connect to it using VNC to use it as a desktop.

    xfce remote desktop

    To install Xfce, enable EPEL repo

    yum install -y epel-release
    

    Install Xfce

    yum groupinstall Xfce
    

    You can see other groups available with command “yum grouplist”.

    Insall vnc server

    yum install -y tigervnc-server
    

    Creating User

    We need to create a normal linux user to use with Xfce. Using it as root is not recommended.

    To create user, run

    useradd -m --shell /bin/bash serverok
    

    Replace “serverok” with whatever username you want to use.

    Configure VNC server

    Change to the user we created before

    su - serverok
    

    To create initial vnc config files and set password, run

    vncserver -fg
    

    We used -fg option to keep vncserver in forground. vcnserver will ask you to set password, this will be used to connect to VNC server.

    When i run “vncserver -fg” on CentOS, it exited with error. If it keep running, press CTRL+C to stop vnc server.

    If you run with out -fg option, you can stop vnc server with command

    vncserver -kill :1
    

    Edit file

    vi /home/serverok/.vnc/xstartup
    

    Replace contents of this file with following

    #!/bin/sh
    
    unset SESSION_MANAGER
    unset DBUS_SESSION_BUS_ADDRESS
    /etc/X11/xinit/xinitrc
    /bin/startxfce4
    

    Now you can start vncserver manually with command

    vncserver -fg
    

    You will be able to connect to VNC server with YOUR_SERVER_IP:1

    Auto start VNC server

    Following need to be done as user root.

    Edit file

    vi /usr/lib/systemd/system/[email protected]
    

    Find

    ExecStart=/usr/bin/vncserver_wrapper  %i
    

    Replaced with

    ExecStart=/usr/bin/vncserver_wrapper serverok %i
    

    reload systemctl

    systemctl daemon-reload
    

    Enable vncserver to start on boot

    systemctl enable vncserver@:1.service
    

    Start vncserver

    systemctl start vncserver@:1.service
    

    Open port in firewall

    You need to open VNC port in firewall. vnc ports start at 5900, for :1, it will be 5901.

    [root@centos7 ~]# netstat -lntp | grep vnc
    tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      1951/Xvnc           
    tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN      1951/Xvnc           
    tcp6       0      0 :::5901                 :::*                    LISTEN      1951/Xvnc           
    tcp6       0      0 :::6001                 :::*                    LISTEN      1951/Xvnc           
    [root@centos7 ~]# 
    

    If you are using firewalld, you can open port 5901 with

    firewall-cmd --zone=public --add-port=5901/tcp
    firewall-cmd --zone=public --add-port=5901/tcp --permanent
    

    firewall-cmd command is run 2 times as first command only make changes in current session. second command with –permanent option make changes permanent, but that only happens after you reload firewalld or reboot server. Running command 2 times make the changes permanent and apply changes to current session.

    See VNC, Remote Desktop

  • Connecting to VNC Server from a Mac computer

    On Windows and Linux there are many free open source VNC clients available. For Mac, if you google, most VNC clients are paid. But you don’t need a VNC client on Mac.

    To connect to VNC server from Mac Computer, go to the terminal, run following command

    open vnc://SERVER_IP_ADDRESS_HERE:PORT_HERE
    

    Example

    open vnc://13.37.18.223:5901
    

    See Mac, VNC

  • Start x11vnc with supervisord

    To auo start x11vnc with supervisord, first install x11vnc and supervisord

    apt -y install supervisor x11vnc
    

    Create a password file

    x11vnc -storepasswd YOUR_SECRET_PW /etc/vncsecret
    

    Replace YOUR_SECRET_PW with whatever password you want to use.

    Create supervisord unit file

    vi /etc/supervisor/conf.d/x11vnc.conf 
    

    Add following content

    [program:x11vnc]
    priority=200
    command=/usr/bin/x11vnc -rfbauth /etc/vncsecret -display :0 -xkb -noxrecord -noxfixes -noxdamage -wait 5 -shared 
    user=USERNAME_HERE
    autorestart=true
    autostart=true
    redirect_stderr=true
    

    Replace USERNAME_HERE with actual user name used to login to system.

    Enable supervisior

    systemctl enable supervisor
    

    You can use following commands to interact with supervisord

    supervisorctl restart all
    supervisorctl reload
    supervisorctl status
    

    See vnc

  • Enable Remote Desktop in Ubuntu 18.04

    Enable Remote Desktop in Ubuntu 18.04

    To enable remote desktop on Ubuntu 18.04 (works with newer Ubuntu versions), go to settings.

    Ubuntu 18.04 settings

    Click on Sharing

    Ubuntu Enable Remote Desktop

    Click on ON/OFF button on title bar to enable Desktop Sharing. Once enabled, click on “Screen Sharing” to See Desktop sharing option, you need to enable it for network connection.

    Ubuntu 18.04 desktop sharing

    Ubuntu use vino package to allow remote desktop over VNC.

    See Ubuntu, VNC, remote desktop

  • Install vnc server on CentOS 5

    NOTE: CentOS 5 reached its End of Life on March 31, 2017. For installing VNC desktop on CentOS 7, see Install Xfce VNC remote desktop on CentOS 7

    Install GUI on Sever

    To find available desktop environments

    yum grouplist
    

    To install gnome

    yum groupinstall "GNOME Desktop Environment"
    

    For KDE

    yum groupinstall "KDE (K Desktop Environment)"
    

    For XFCE, install

    yum groupinstall "XFCE"
    

    XFCE file size in fedora 12 Total download size: 105 M, Installed size: 363 M

    Install VNC Server

    yum install vnc vnc-server
    

    Start VNC Server

    [root@pc7 ~]# vncserver
    
    You will require a password to access your desktops.
    
    Password:
    Verify:
    xauth:  creating new authority file /root/.Xauthority
    
    New 'pc7.localdomain:1 (root)' desktop is pc7.localdomain:1
    
    Creating default startup script /root/.vnc/xstartup
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/pc7.localdomain:1.log
    
    [root@pc7 ~]#
    

    Now stop vnc server with

    pkill -9 vnc
    rm -rf /tmp/.X*
    

    Set Password for VNC Server

    vncpasswd /root/.vnc/passwd
    
    [root@pc7 ~]# vncpasswd /root/.vnc/passwd
    Password:
    Verify:
    [root@pc7 ~]#
    

    Edit xstartup

    vi  /root/.vnc/xstartup
    

    Find

    twm &
    

    Replace it with

    For Gnome

    gnome-session &
    

    For XFCE

    startxfce4 &
    

    For KDE

    startkde &
    

    For FVWM2

    fvwm2 &
    

    After change, it will look like

    [root@pc7 ~]# cat /root/.vnc/xstartup
    #!/bin/sh
    
    vncconfig -iconic &
    # Uncomment the following two lines for normal desktop:
    # unset SESSION_MANAGER
    # exec /etc/X11/xinit/xinitrc
    
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    gnome-session &
    [root@pc7 ~]#
    

    Create VNC Users

    vi /etc/sysconfig/vncservers
    

    Add

    VNCSERVERS="1:flashwebhost"
    

    Start VNC Server

    [root@pc7 ~]# vncserver
    
    New 'pc7.localdomain:1 (root)' desktop is pc7.localdomain:1
    
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/pc7.localdomain:1.log
    
    [root@pc7 ~]#
    

    Connecting

    Start tightVNC Viewer, connect to IP-ADDR:1 to connect as user root.

    See VNC server