Do you want to get a cloud cert?
Want free certification prep?

Get #CloudHappy with FREE course prep from Pluralsight.
Click here to start!


I recently added some new drives and hardware to my FreeBSD 13 server. I use this machine to run virtual machines for my courses and various experiments. I like to have a desktop handy to manage VirtualBox or perform other desktop tasks.

I could use Remote Desktop from Windows to access it, but I couldn’t remember how I set it up. The instructions available online aren’t super clear, so this time when I set it up, I documented it, and now I’m sharing it with you.

We’ll use XRDP to connect to a FreeBSD machine with RDP from Windows, Mac, or Linux.

Enable SSH

If you don’t already have it, the first thing you’ll need is SSH access. Log in under root.

Open up /etc/rc.conf (I use Vim, but you can use whatever editor you like)

vim /etc/rc.conf

Add the following line to /etc/rc.conf:

sshd_enable="YES"

Then run the following to start up sshd:

/etc/rc.d/sshd start

Now you’ll be able to SSH into your machine, which is needed for remote desktop.

Installing xrdp

The xrdp package is awesome for setting up a remote desktop. With this app, you can set up RDP, VPN, or other connections easily. But it’s not always easy to configure with FreeBSD. That’s changed a lot over the years.

The latest version, with FreeBSD 13, is pretty straightforward.

To install it, as root type in:

pkg install xrdp

or if you prefer to build it from ports:

cd /usr/ports/net/xrdp/ && make install clean

Once that’s done, you’ll need to edit /etc/rc.conf again and add the following lines:

xrdp_enable="YES"
xrdp_sesman_enable="YES"

And then reboot your machine.

Configuring your Window Manager

If you connect now, you’ll go to Xterm. Not ideal. So if you open up /usr/local/etc/xrdp/startwm.sh as root, you’ll see your options:

Remote Desktop FreeBSD

You can either uncomment one of these and save the file or create your own ~/.startwm.sh in your user folder. This is what I do so different users can have other desktops selected.

I’m using LDXE(meta) for my desktop, which isn’t listed here.

So I created a ~/.startwm.sh file and added the following line:

exec startlxde

and save the file. Now it’s ready to start up!

Starting up

So now you’ve rebooted, and you’re ready to go. You load up Windows Remote Desktop, put in your IP, and you’ll see this:

Remote Desktop FreeBSD

Which is normal if you don’t have a certificate set up. Next, you’ll be greeted with a login screen:

Remote Desktop FreeBSD

Here you enter your user credentials (not root!!).

And here’s my desktop!

Remote Desktop FreeBSD

Conclusion

I couldn’t find any step-by-step instructions for doing remote desktop in FreeBSD with LXDE, so I decided to document this. In the past, it’s been even more difficult, but now it’s fairly easy.

Now I can connect to my FreeBSD desktop from:

This allows me to jump on my FreeBSD desktop any time and do what I want. If you’re looking for the same experience, I hope this tutorial has helped.

Questions? Comments? Yell at me!


Do you want to get a cloud cert?
Want free certification prep?

Get #CloudHappy with FREE course prep from Pluralsight.
Click here to start!


Published: Mar 10, 2022 by Jeremy Morgan. Contact me before republishing this content.