Configure Multiple Users for Shadowsocks-libev
The original Python release of shadowsocks supports multiple users through configuration, by assigning different passwords on multiple ports.
1 | { |
Currently I am using shadowsocks-libev
, which is the libev port of shadowsocks. And I also need to support the usage of multiple users. According to Madeye’s reply to the GitHub Issue, shadowsocks-libev does not support multi-port configuration:
Sorry, we have no plan to support multi port configuration. Actually you can use multiple instances instead. For example:
1 | ss-server -c config1.json -f pid1 |
As the best practice we recommend for
shadowsocks-libev
, it helps to isolate each user in different processes and reconfigure each user’s port/password/encryption/timeout without reload/restart the whole service. Furthermore, this approach enables us to manage users with legacy control panels, for example old SSH / VHOST panels with each user’sss-server
running in its own space.Compared to other implementations,
shadowsocks-libev
uses much fewer resources (about 1MB memory and hundreds of file descriptors in a typical usage) . As a result, this kind of multi processes should only introduce slight overhead and even works well for low end boxes.
I choose to use systemctl
to manage the systemd
instances of shadowsocks-libev
. The following template unit files are installed in the /lib/systemd/system
directory:
1 | shadowsocks-libev-local@.service |
Take a look at the template unit file shadowsocks-libev-server@.service
:
1 | [Unit] |
With the help of template unit files, service instances could be deployed and managed easily. For example, Cloud and Tifa, two AVALANCHE members, are planning to deploy shadowsocks-libev
services on the same VPS to bypass the firewall of Shinra Inc. In this case, they could simply create cloud.json
and tifa.json
configurations with different ports, passwords and encryption methods in /etc/shadowsocks-libev
directory. Then enable and start the systemd
services using the following commands:
1 | sudo systemctl enable shadowsocks-libev-server@cloud.service --now |
The status of shadowsocks-libev
instances could be checked with the following commands:
1 | sudo systemctl status shadowsocks-libev-server@cloud.service |
That’s all done. Enjoy!
Configure Multiple Users for Shadowsocks-libev
https://blog.zzhou612.com/2019/02/15/configure-multiple-users-for-shadowsocks-libev/