Use shadowsocks in Linux (taking ubuntu16.04 as an example, not a server ),

Source: Internet
Author: User

Use shadowsocks in Linux (taking ubuntu16.04 as an example, not a server ),

System Environment: Ubuntu 16.04

Install

Run the following commands in different Linux distributions (it is best to run the following command under root, for which I will explain below ):

Debian / Ubuntu:apt-get install python-pippip install shadowsocksCentOS:yum install python-setuptools && easy_install pippip install shadowsocks
Configuration

Sudo vim/etc/shadowsocks. json
// The json file is created by yourself, not the built-in file.

The configuration file is roughly as follows:

{"Server": "server ip Address", "server_port": server port, "local_address": "127.0.0.1", "local_port": 1080, "password ": "password", "timeout": 300, "method": "aes-256-cfb", "fast_open": false}
Start the ss Client

The first two steps are very simple, but some people are wondering how to use them after installation. In fact, you can use sslocal-help to view the help information.

Sslocal-c/etc/shadowsocks. json

A command proxy can be started.
The shadowsocks cannot be started. We also need to set the relevant proxy.

Convert HTTP Proxy

Shadowsocks uses the Socks5 protocol by default. There is no way to switch the get and wget of Terminal to the Http protocol. Therefore, it is necessary to convert the Shadowsocks into an Http proxy to enhance universality, the conversion method used here is based on Polipo.

Run the following command to install Polipo:
Sudo apt-get install polipo

Modify the configuration file:
Sudo gedit/etc/polipo/config

Replace the following content with the file and save it:

    # This file only needs to list configuration variables that deviate    # from the default values. See /usr/share/doc/polipo/examples/config.sample    # and "polipo -v" for variables you can tweak and further information.    logSyslog = false    logFile = "/var/log/polipo/polipo.log"    socksParentProxy = "127.0.0.1:1080"    socksProxyType = socks5    chunkHighMark = 50331648    objectHighMark = 16384    serverMaxSlots = 64    serverSlots = 16    serverSlots1 = 32    proxyAddress = "0.0.0.0"    proxyPort = 8123

Restart Polipo:
/Etc/init. d/polipo restart

Verify that the proxy is working properly:
Export http_proxy = "http: // 127.0.0.1: 8123 /"
Curl www.google.com

If it is normal, the captured Google webpage content will be returned.

In addition, enter http: // 127.0.0.1: 8123/in the browser to go to The Polipo usage instructions and configuration interface.

Configure the browser

In firefox

Preference-> advanced-> network-> connection-> settings select to manually set the proxy, and set the http proxy to 127.0.0.1 port 8123 (that is, the port configured in step 2)
This step should be able to be accessed through shadowsocks, but the computer I encountered still does not work. Later, I used "Use this proxy server for all protocols" under the http proxy to apply the proxy to all protocols) "This can also be hooked up.

PS. If you skip step 2, configure the http proxy to port 127.0.0.1 1080 in step 3. In some articles, this is the case, but you cannot connect to the Internet.

Ubuntu runs automatically after it is started

Now you can access the Internet scientifically, but you have to manually open the terminal to enter a command every time you start the system. Although this command is not long, you have to manually enter it every time, and it seems quite low, and the terminal proxy is disabled.

Write a script

We can create a new file named shadow. sh under/home, for example, write the command we need to start the ss client, and then save it.

#!/bin/bash#shadow.shsslocal -c /etc/shadowsocks.json

Check whether the command sh/home/shadow. sh can be executed on the terminal. If the command is successful, information will be output. You can also try it in the browser. At this time, even if you enter less, but the terminal is closed, we can let him run in the background, nohup sh/home/shadow. sh &.

Add to start running

Here, we need to edit a file named rc and local under/etc. We need the root permission and su will get the root permission first on the terminal.

Here the problem arises, because we need to start the system and use the root permission to execute the previously written script. However, if your shawdocks is not under the root, an error will be reported when you execute the script:
"Traceback (most recent call last ):
File "/home/gaoxw/. local/bin/sslocal", line 7, in
From shadowsocks. local import main"
If you use sudo for installation, the above error will still be reported.

If you have a root account, edit vim/etc/rc. local and enter nohup bash/home/shadow. sh>/home/d.txt & Save before exit.

Now you can rebootand restart the server. The test shows that the server cannot be automatically run on the backend server. You can check whether the d.txt output is/home/shadow. sh line 3: sslocal: command not found, and the browser cannot be connected to the proxy server.

After some searches, we found that the sslocal command was not found far away from linux? You need to add the path. We found that the sslocal and ssserver commands exist under/usr/local/bin. In fact, you do not need to add them to the profile, you can directly move these two files to/bin.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.