Establish Private VPN on VPS

Preparation

VPS

What is VPS?

The defination of VPS is quoted from wikipedia.

virtual private server (VPS) is a virtual machine sold as a service by an Internet hosting service.

A VPS runs its own copy of an operating system (OS), and customers may have superuser-level access to that operating system instance, so they can install almost any software that runs on that OS. For many purposes they are functionally equivalent to a dedicated physical server, and being software-defined, are able to be much more easily created and configured. They are priced much lower than an equivalent physical server. However, as they share the underlying physical hardware with other VPSs, performance may be lower, depending on the workload of any other executing virtual machines.

Purchase VPS

There are many VPS supportors on the website, the one that I used is bandwagonhost.

First, register on the bandwagonhost website, and then click order KVM or OpenVZ button on the homepage to order VPS. Choose the product you want to buy, and click Order KVM button. I recommend you to order KVM rather than OVZ. For me, I chose the first product (10G VPS: 10GB SSD, 512MB RAM and 500GB bandwidth) and ordered KVM. After that, choose Billing Cycle and Location (I recommend US – Los Angeles DC2 QNET (USCA_2) and  US – Los Angeles DC4 MCOM (USCA_4) which are faster.)  and click Add to Cart button, and then click Checkout button to purchase. PayPal, Alipay and Credit Card is supported on this website, choose one of those you like to purchase.

After purchasing, go back to homepage and click Client Area button on the up-right corner of the homepage. Then, click Services->My Services button and the VPS you just ordered appears on the page. Click KiwiVM Control Panel button to go to KiwiVM Control Panel. There are some very import information on Main Controls tab of KiwiVM Control Panel, such as

  • IP address
  • SSH Port
  • Disk usage
  • Bandwidth Usage
  • Operating system

The last import thing we need to do is to get root password which is used to connect VPS through Xshell SSH connection (Xshell will be talked later in this passage). There are two kinds of way to approach.

  1. Use Root pasword modification on KiwiVM Control Panel.
  2. Use Install new OS on KiwiVM Control Panel.
    Choose a new Operating System you would like to install, and check the checkbox and click Reload. After that, a prompt information including a new root password and new SSH port will come up on the screen. Copy and save this important information (It’s very important, especially the root password. There is no way to find it out if you lost it except generate a new root password or install new OS to get a new root password).

Congratulation! The preparation for VPS complete!

Xshell

What is Xshell?

The properties of Xshell is quoted from official website.

Xshell is a powerful terminal emulator that supports SSH, SFTP, TELNET, RLOGIN and SERIAL. It delivers industry leading performance and feature sets that are not available in its free alternatives. Features that enterprise users will find useful include a tabbed environment, dynamic port forwarding, custom key mapping, user defined buttons, VB scripting, and UNICODE terminal for displaying 2 byte characters and international language support.

Download

Generally, Xshell should be purchase, but a free license (Home and School use) is offered by official, click this link to go to free license page and download.

Install & Usage

Install & Usage is talked about on this page.

Connect VPS through Xshell SSH connection

Prepare IP address and SSH port

Get IP address and SSH port on KiwiVM Control Panel.

Creating a session

You can create Telnet, Rlogin and SSH protocol sessions.

  1. On the File menu, click New.
    RESULT: New Session Properties dialog box opens.
  2. In the Name box, enter the name for the session. (Anything you want to type as a name.)
  3. In the Protocol list, choose a protocol to use when connecting to the remote server. (Here we choose SSH)
  4. In the Host box, enter the hostname or IP address of the remote server. (Here we enter IP address of VPS we prepared before.)
  5. In the Port Number box, type or select the port number used by the remote server. (Here we enter SSH port number we prepared before.)
  6. Click on the Authentication in the category menu.
  7. In the User Name box, enter the name of your account on the server.  (Here we enter root.)
    Note: Prompt dialog box will open during authentication process if the user name is not specified.
  8. Click OK.

A new session has been created and you are ready to connect to the remote host. To connect to the remote host, read the Connecting to the remote host section below.

Connecting to the remote host

Once you have created a Telnet, Rlogin or SSH session, you can connect to the remote host. If there is no session created, see Creating a session first.

  1. On the File menu, click Open.
  2. In the session list, select the session you want to connect to. And click Connect.
    The SSH User Authentication dialog box shows up.
  3. For the password authentication, enter your password in the Password box, and click OK.For the public key authentication, select a user key from the list and type in the passphrase in the Passphrase box and click OK.
    Note: If there is no user key available, see Public Key User Authentication.For the keyboard-interactive (Generic Message Exchange) authentication, click OK and then follow the generic authentication steps.Note: You can skip the authentication steps by saving the password and/or public key information in the Authenticationcategory of the Properties dialog box.

Shadowsocks

Remote VPS Installation and Usage

The following configuration information can be accessed in ss github website.

Install

The first step in official set is to run apt-get install python-pip command, but error occurs like this:

root@debian:~# apt-get install python-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python-pip

To solve this problem, run apt-get update, after that, run apt-get install python-pip.

Debian / Ubuntu:

apt-get install python-pip
pip install shadowsocks

CentOS:

yum install python-setuptools && easy_install pip
pip install shadowsocks

Then run pip install shadowsocks command.

Usage

First, to confirm vim is installed on your environment. If not, run apt-get install vim command.

vim /etc/shadowsocks.json

For single user

{
    "server":"my_server_ip",    # you should change my_server_ip to your real IP
    "server_port":8388,
    "local_address": "127.0.0.1",
    "local_port":1080,
    "password":"your_password", # you should set a password for you
    "timeout":300,
    "method":"aes-256-cfb",
    "fast_open": false
}

For multi-user

{
"server":"my_server_ip", # you should change my_server_ip to your real IP
"local_address":"127.0.0.1",
"local_port":1080,
"port_password":{
                "443" :"your_password_1", # you should set a password for you
                "8381":"your_password_2", # you should set a password for you
                "8382":"your_password_3", # you should set a password for you
                "8383":"your_password_4", # you should set a password for you
                "8384":"your_password_5"  # you should set a password for you
        },
"timeout":300,
"method":"aes-256-cfb",
"fast_open":false
}

Explanation of the fields:

NameExplanation
serverthe address your server listens
server_portserver port
local_addressthe address your local listens
local_portlocal port
passwordpassword used for encryption
timeoutin seconds
methoddefault: “aes-256-cfb”, see Encryption
fast_openuse TCP_FASTOPEN, true / false
workersnumber of workers, available on Unix/Linux

The next step is to tart ssserver, use ssserver -c /etc/shadowsocks.json -d start command.

If ssserver already start, error will occur when running the above command, and the error is

INFO: loading config from /etc/shadowsocks.json
2017-09-04 19:15:21 INFO     loading libcrypto from libcrypto.so.1.0.0
2017-09-04 19:15:21 ERROR    already started at pid 15649

So, use ssserver -c /etc/shadowsocks.json -d stop command to stop the ssserver and use ssserver -c /etc/shadowsocks.json -d start command to start the ssserver. If ssserver starts successfully, you will get the following information

INFO: loading config from /etc/shadowsocks.json
2017-09-04 19:15:35 INFO     loading libcrypto from libcrypto.so.1.0.0
started

Congratulations! Shadowsocks is installed and configured completely until now.

Windows Shadowsocks client

Download

Click here to download Shadowsocks for Windows.

Usage

The usage of Windows Shadowsocks client is here.

Android Shadowsocks client

Click here to install Android Shadowsocks client. You may not open this link, and you can download here or search 影梭.

IOS Shadowsocks client

Click here to install IOS Shadowsocks client.

3 thoughts on “Establish Private VPN on VPS

发表评论

电子邮件地址不会被公开。 必填项已用*标注

3 + 2 =

70 − 63 =