Installing TigerVNC on FreeBSD

I have a daily driver, my Mac Studio, and I have the Raspberry Pi as a Lab of sorts. A safe place to bring out Dr. Jekyll, a mirror dimension if you will. I need to access that lab, I can do that through SSH, if you just want to access the terminal, but I like using a GUI. Therefore, I am installing TigerVNC. There are other VNC solutions out there, but I just chose this one. I know I need TigerVNC viewer to access it using the Mac, but life is not perfect. Reading everyone’s divergent opinion on what VNC Server to use takes too much effort. I followed server-world’s instructions.

To install the VNC server it is pretty straight forward. The -y automatically fills in yes for the installation prompt.

After installation, you want to run the server for the first time. Using the account you want to use to vnc into the computer, enter the following command.

You will get a prompt to enter password for vnc, and also a view-only password. Once it is done it will create the necessary files.

After this you want to edit the xstartup file using nano.

Add the following lines to the xstartup file and save it.

Now you want to make the xstartup file executable.

To start the vncserver you can just use the vncserver command. It is the vncserver command followed by the display number.

This starts the session on port 5900 + 0

Setup VNC as a Service for Start at Boot

Now you probably want to startup the vncserver at boot time. To do this I finally found one way to do this that works. You first create a script to start the vnc server in your bin directory. Assuming you are in your super user account.

Enter the following in to the script and save. Make sure to updated the entries for your_username, and the path to your vncpassword

I made the script executable for root, and for the freebsd user by running the following command in both sessions.

The next step is to setup a service to execute this at boot time. In the super user account, edit the vncserver config script for rc.d.

In this file add the following.

You then wish to enable the server in the rc.conf file, using sysrc.

Finally you can start the service to test it out, it will start automatically after the next boot.

Test out VNC session using MacOS

In your finder enter Cmd+K and in the “Connect to Server” dialog box, enter :

vnc://<Machine IP address>:5900

Connect, and enter your password when the dialog box pops up. You are now set, you can log in to FreeBSD using the password for the freebsd user.