Introduction

Shadowsocks is a fast tunnel proxy that helps you bypass firewalls and block certain websites and web protocols. It is also a lightweight, fast and Flexible Encrypted Socks5 proxy. In that SOCKS5 is an internet protocol of SOCKS that helps to route packets through a proxy between a client and a server. Additionally Shadowsocks is an open source free encryption protocol client.

Now we use Shadowsocks-libev package on Ubuntu server for setting the shadowsocks server. Shadowsocks-libev is written in pure C and depends on libev. It’s designed to be a lightweight implementation of shadowsocks protocol, in order to keep the resource usage as low as possible on embedded devices and low-end boxes.

section 1. Install the Shadowsocks Server

In this section we install shadowsocks-libev from GitHub source code. Please note that all commands we have to be run as root, e.g. using sudo or su.

To start off, first log into the OpenVPN ubuntu server through SSH terminal.

Now from the SSH terminal issue below  command

Copy to Clipboard

This command will Download and update the packages to the newest versions on Ubuntu. Normally it will take some time to complete the update process. So lets wait until it get completed.

So now Install dependencies on the Ubuntu server by running the command

Copy to Clipboard

Confirm the install by typing Y and wait until the command execution got completed. We can get this dependencies list from the official website of Shadowsocks itself.

After that download the Shadowsocks Git module by executing the below command. So lets issue this command in the terminal and wait until it got completed.

Copy to Clipboard

After that go the folder “shadowsocks-libev” by issuing the below command . So lets issue this command in the terminal.

Copy to Clipboard

Now update the Git submodules in our workspace by issuing the below command . So lets issue this command in the terminal and wait until it got completed.

Copy to Clipboard

Now lets Install Shadowsocks-libev by executing the below commands. These commands can be combined using logical and operator. So lets issue this command in the terminal and wait until it got completed.

Copy to Clipboard

This Concludes the install of shadowsocks packages in the Ubuntu server. Now lets move to the next section.

Section 2. Configure the Shadowsocks Server

In this section we disuss how to use Shadowsocks libev after its installation. For that create a system user and add that system user to Shadowsocks. Later create a directory with Shadowsocks configuration file.

so go back to our ssh terminal and issue below command . This command will create a user named shadowsocks without home directory . So lets issue this command in the terminal.

Copy to Clipboard

After that Create a new directory for the Shadowsocks configuration file. For that issue below  command .

Copy to Clipboard

Now Create the Shadowsocks configuration file ” /etc/shadowsocks/shadowsocks.json ” using vim editor and Paste the contents shown in the screen.

So first issue below command in the terminal. After that in the insert mode, paste the content that shown in the screen.

Copy to Clipboard
Copy to Clipboard
In that the Property “server ” defines the public ip of our Shadowsocks server. So replace it with your server IP
The property ” server_port ” defines the port number of Shadowsocks server uses. The default port is 8388
The property ” password ” defines the password need to be used for Shadowsocks clients for connection.
The property ” timeout ” defines the connection timeout.
The property ” method ” defines the Encryption method used between Shadowsocks server and client
The property ” fast_open ” value true defines to Reduce latency when turned on Shadowsocks

So lets Save the content in the file and exit.

Now we can optimal kernel configuration for Shadowsocks server by adding the content shows in the screen over to the file named ” /etc/sysctl.conf ” . So for that first open the file using below command  and I am issuing this command in the ssh terminal.

Copy to Clipboard

After that I added the content that  given below . These parameters can be get from the official website of Shadowsocks. In our case I added the entry towards the end of the file.

Copy to Clipboard

The priciples of using these tuning parameters for shadowsocks server are

Reuse ports and conections as soon as possible.
Enlarge the queues and buffers as large as possible.
Choose the TCP congestion algorithm for large latency and high throughput.

So lets save the content and exit. After that execute below command to reload the config at runtime and I am issuing this command in the ssh terminal.

Copy to Clipboard

Now lets Create a Shadowsocks Systemd Service to automatically start the Shadowsocks service on system boot and run in the background. For that first create the file ” /etc/systemd/system/shadowsocks.service“. For that issue below command  in the ssh terminal. So I am issuing this command in the terminal.

Copy to Clipboard

After that in the insert mode, add the content that shows below.

Copy to Clipboard

Save the conent and exit. Later Enable and start shadowsocks.service by issuing below commands.

Copy to Clipboard

Once the service got started. Allow the port 8388 in the server firewall. Usually on ubuntu we use ufw firewall and the command will be like below.

Copy to Clipboard

So lets issue above command in the ssh terminal. This completes the configuration of Shadowsocks server. Now lets move to the next section.

Section 3. Install Shadowsocks Client and Connect

In this section we install Shadowsocks Client on a user’s device. In our case the user device is also a Ubuntu 20 lts desktop version.

so in our client terminal, issue below command  for Shadowsocks Client. So lets issue this command in the terminal. Confirm the package install by typing “y” and wait until it got installed. The shadowsocks-libev package contains both the server software and client software.

Copy to Clipboard

The Shadowsocks-libev (the server) service will automatically start after being installed. But we need to stop Shadowsocks server on our Ubuntu desktop. For that issue below commands. So lets issue those commands in the terminal.

Copy to Clipboard

Now we need to create the client-side configuration file. For that create a file named /etc/shadowsocks-libev/local-config.json . For that issue below command  in the terminal.

Copy to Clipboard

After that add the content shows in the screen.

Copy to Clipboard

Save and close the file. Then we can start the client by issuing below command  .So lets issue the command in the terminal.

Copy to Clipboard

Now enable auto-start at boot time by issuing below command . So lets issue the command in the terminal.

Copy to Clipboard

We can also Check its status and Make sure it’s running by issuing below command . So lets issue the command in the terminal.

Copy to Clipboard

Now the ss-local process listens on 127.0.0.1:1080 on our Ubuntu desktop and it’s connected to our Shadowsocks server. Which means The local proxy creates a connection to our shadowsocks server and allows data to pass through them. To actually have application data to use this proxy, we need to configure our web browser or operating system to use the local proxy.

So lets see how this can done on Firefox web browser.

  • In firefox click on Open Application menu at the top right side corner
  • In that click settings option. Then scroll down to the bottom and click Settings in Network Proxy.

  • In the Connection Settings window, select manual proxy configuration. Then select SOCKS v5 because Shadowsocks is a Socks5 proxy. Enter 127.0.0.1 in the SOCKS Host field and 1080 in the port field. Make sure “Proxy DNS when using SOCKS v5” is enabled. Click OK to apply these modifications.

After that Verify the Shadowsocks connection is active by visiting an IP address lookup website like https://whatismyipaddress.com/. When the connection is working as expected, the website lists the Shadowsocks server public IP.

Conclusion

Okay, This concludes how to how to install shadowsocks on Ubuntu. I hope this blog article is informative  and also Leave your thoughts at the comment box.

Share This Story, Choose Your Platform!