Set up Shadowsocks on an Ubuntu VM in Azure for VPN purposes

build a shadowsocks server in Azure

Shadowsocks is one of the techniques that you can use to set up your VPN equivalent server. With Microsoft Azure, you can quickly set up a Ubuntu virtual machine (VM) to host Shadowsocks. But why Ubuntu? Simply because it demands less Azure resource from the cost-saving perspective than other available operating systems. Don’t worry if you barely have the knowledge in Azure or Ubuntu. Follow the steps in the article and you will get there.

Monthly cost of a Shadowsocks server in Azure

Before we start, let’s take a look at the cost of a Shadowsocks server in Azure.

  • VM (Ubuntu): 22.32$/month.
  • Bandwidth: Monthly cost of the first 5GB for free and 0.138$/GB onward for incoming traffic. Outbound traffic from Azure is free.

Let’s say you used 105 GB incoming data in a month which turns out to be 13.8$. Plus the VM cost, you get a total of 36.12$ for that month.
Note: The actual cost may vary over time and the geo region the VM sits in.

To set up Shadowsocks in Azure, you need to:

  1. Set up a Ubuntu server in Azure.
  2. Create a port on the server for Shadowsocks connection.
  3. Set up and configure Shadowsocks.

Now let’s start.

Set up a Ubuntu server in Azure

  1. Open the Azure portal, and log in with your Azure account (Get a one month free trial of Azure with 200$ credit).
  2. Click New, type Ubuntu, and then press Enter.
  3. Select Ubuntu Server 17.04 in the list of matches, and start creating one with the Resource Manager deployment model.
  4. Proceed with the following configuration for the setup:
    • Use the Basic A1 plan at 22.32$/month.
    • Set the Authenticate type to use Password.
    • Create a new resource group to host the server.
    • Set Public IP address to Static.
  5. Once the server is created, note down the Public IP address.

Create a port on the server for Shadowsocks connection

  1. Go to the resource group where the VM is hosted, find and open the <server>_nsg resource.
    This resource functions as the firewall for the server. It comes with a pre-configured inbound security rule to allow management through SSH on TCP port 22.
  2. Add an inbound security rule by providing a name and port, and leave the rest with the default value. Here I set the port to 2000.

Set up and configure Shadowsocks

  1. Use an SSH client to connect to the Ubuntu server using the public IP address, which you noted down earlier, for remote management. PuTTY is the client I use on Windows.
    Upon connection, an SSH client window opens.
  2. Install ShadowSocks by running the following command:
    sudo apt install shadowsocks-libev
  3. Configure Shadowsocks.
    1. Open the config.json file.
      sudo vim /etc/shadowsocks-libev/config.json
    2. Press I to switch to the editing mode.
    3. Update the following settings in the file:
      • Set server to
      • Set server_port to the port you created in the <server>_nsg resource.
      • Set password to the password of your Ubuntu server.
      • Set method to “aes-256-cfb”.
    4. Press ESC, and then type :wq to save the file.
  4. In the Azure portal, restart the Ubuntu server.
    Note: The setup has configured Shadowsocks to automatically start with Ubuntu.
  5. Verify if the ShadowSocks server is listening on the port, in this case 2000.
    netstat -lnp
    If the port was not listened, restart ShadowSocks.
    service shadowsocks-libev restart
  6. Download the Shadowsocks client that is available on Android, iOS, Windows and macOS. For Android and iOS, you may have to get the client from the US app store.
  7. Open the Shadowsocks client, enter the connection information and make the connection. You also have the option of enabling Shadowsocks to handle the traffic only to sites outside of China.

Congratulations! Now you are all set. Enjoy Shadowsocks!

Continue reading “Set up Shadowsocks on an Ubuntu VM in Azure for VPN purposes”