1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Setting up a VNC server

Discussion in 'Web and Network Services' started by agottem, Nov 16, 2011.

  1. agottem

    agottem New Member

    Messages:
    26
    Thanks Received:
    1
    I've searched the forums and Google, but haven't been able to find a good tutorial on setting up a VNC server. I'm new to FreeBSD, so I apologize in advance if there's good documentation out there that I've missed.

    Here's what I'd like to do: upon startup, I'd like my FreeBSD server to start a VNC server I can connect to remotely via SSH. I'm worried about doing it incorrectly, and introducing security risks.

    Thanks,
    Andrew
     
  2. izotov

    izotov New Member

    Messages:
    118
    Thanks Received:
    6
    What I use is the net/tightvnc port.
    Once it is installed you might start it as regular user with the command % vncserver
    If this is the first time you start vncserver you must provide a password that will later be used when you log in with the VNC client.
    In the output of vncserver command look for someting like
    Code:
    desktop is domain.host:2
    This helps you to create the port number to connect from the client, in this case it is
    Code:
    domain.host:5902

    Additional setup might be done in ~/.vnc/xstartup.

    For launching at startup time please consult the rc(8) manpage.
    For help about starting the server see the vncserver(1) manpage.
     
  3. stralle

    stralle New Member

    Messages:
    5
    Thanks Received:
    1
    You can set which port to use by starting vncserver(1) with the argument -rfbport so you don't have to scan through the logfile to find out.

    I have a rc.subr(8) script that does the following as its final thing when fed the start argument in order to have the vnc server start automatically:
    % su user -c ". /home/user/.bashrc; /usr/local/bin/vncserver -rfbport 5900 -geometry 1152x870 -depth 16 -alwaysshared -name $(hostname -s)"

    Sourcing .bashrc is in order to get the $PATH variable correct. My ~/.vnc/xstartup then simply contains the command to start my windowmanager of choice.

    By using portforward through an ssh client, I can connect to this vnc server wherever I can ssh out from by simply connecting to localhost:5900 and the ssh tunnel does the rest.
     
  4. agottem

    agottem New Member

    Messages:
    26
    Thanks Received:
    1
    Both your replies were very useful. Thanks for the help!