How to RDP into a Windows Server from your remote macOS

This guide will help you connect remotely from your macOS machine to a target Windows Server already configured to support Cloudflare Access.

Cloudflare Access is a solution for working with Windows Servers since they didn't allow for SSH until 2018. To better understand the differences between RDP and SSH protocols, I suggest this blog.

1. Prepping your machine

First things first, if you don't have it yet or are starting in a new machine, I strongly suggest to install Homebrew , THE package manager for macOS. If you haven't installed or updated the CLI tools for Xcode, the download might take longer. (I will write another post soon on how to get the most out of your macOS terminal, brew, zsh and so on).

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Now we need to install the Cloudflare Daemon, let's use our freshly installed package manager for that.

brew install cloudflare/cloudflare/cloudflared

If you choose not to install Homebrew, you can also install the Cloudflare Daemon the old curl way.

curl https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-darwin-amd64.tgz | tar xzC /usr/local/bin

2. Authentication and connection

Once the daemon is installed in your macOS machine, let's authenticate it. You will run the following command which will forward you to your default browser, asking you to login. You must login to the Cloudflare account that set up Cloudflare Access on the server. If you don't have this credentials, contact your sysadmin to work the authentication together.

cloudflared login

Once you've authenticated the daemon on your machine, you're ready to access the server! Use the following command in your terminal filling in your server's hostname and RDP port.

cloudflared access rdp --hostname rdp.your-hostname-here.com --url localhost:your-port-here

If your connection was successful, you'll see something like this:

INFO[2020-07-24T19:42:42-06:00] Start Websocket listener on: localhost:your-port-here

The connection will stop if your internet connection is interrupted or if you ctrl + C the process in the terminal. To resume the connection you can either rerun the cloudflare access rdp command or save a shortcut as explained later in this tutorial.

3. Setting up Microsoft Remote Desktop

After setting up the connection you'll probably want to work inside the Windows Server from your machine. A way of achieving this is by using the Microsoft Remote Desktop client. I suggest downloading it from the App Store.

After downloading Microsoft Remote Desktop, we're going to add a new PC and enter the following information. Your PC name will be localhost:your-port-here and the user account will be the user and the password your sysadmin made for you in the Windows Server.

Image 7-26-20 at 12.53.jpg

Now you're all set up and ready to work. Good luck! 😊