Before we start
In order to follow this guide, I assume you already have a VPS and facing an intranet situation which you can't expose a port to the public. If you have extranets, DDNS is more suitable for you. I will use a Ubuntu 18.04 machine for this guide. The command line will differ among different machine types. Make sure you fully aware of that. So, Let's dive right in.
Use any of your favorable SSH clients to connect to the VPS, Then follow the command below:
## First create a folder for your nps service mkdir nps ## cd to that directory cd nps ## pull the nps file (in this guide, I will use amd64 version of nps, please choose the suitable one for your own machine) wget https://github.com/ehang-io/nps/releases/download/v0.26.6/linux_amd64_server.tar.gz ## untar the file tar -xvf linux_amd64_server.tar.gz ## see the relevant files ls ## install the nps sudo ./nps install ## navigate to the nps config file folder cd /etc/nps ## modify the config setting to suit your need nano conf/nps.conf ## start the nps sudo nps start ## access the dashboard Access server IP:web service port (default is 8080).
Login with username and password (default is admin/123, must be modified when officially used).
Connect a client
Create a client on the NPS portal. I will demonstrate how to connect to my home router and NAS in this example. First, choose the client on the left panel, then choose a remark for your client. You can leave all the other fields blank, click Add when you finished.
Login to your router and input your server ip, port, and vkey, then connect to the NPS (It's highly recommend to put this kind of service on your primary router).
Create a TCP profile to connect to your home router. In this example, I use server IP:9000 to access my home router address as 192.168.123.1:80.
You can also install NPS as Docker image, the docker way is describe below. ## Install Docker on VPS
First, Use any of your favorable SSH clients to connect to the VPS, Then follow the command below: The following command is used for CentOS only.
## this will update your system packages sudo yum update ## this will install the required dependencies sudo yum install yum-utils device-mapper-persistent-data lvm2 ## add the Docker stable repository to your system: sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo ## install the latest version of Docker CE sudo yum install docker-ce ## start the Docker daemon and enable it to automatically start at boot time sudo systemctl start docker sudo systemctl enable docker ## verify that the Docker service is running sudo systemctl status docker ## check the Docker version docker -v
Now, the Docker should be installed and running on your machine. But by default managing, Docker requires administrator privileges. If you want to run Docker commands as a non-root user without prepending sudo you need to add your user to the docker group which is created during the installation of the Docker CE package. You can do that by typing:
sudo usermod -aG docker $USER
Log out and log back in so that the group membership is refreshed. Then you should be able to run docker commands without sudo. Now, let's test it by typing:
docker container run hello-world
If you get the message like below, you're good to go:
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 9bb5a5d4561a: Pull complete Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly.
Install NPS to the Docker
docker pull ffdfgdfg/nps
You can manage your Docker image better with GUI interface by using Portainer. This is optional, but I will install Portainer in this case.
docker volume create portainer_data docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
Now, you can access Portainer dashboard by entering your VPS IP:9000, you will create an administrator account when you first login. Choose local to connect with your Docker. Then you can check the NPS image you just pulled by going to the images tab.
Modify the Conf file
Download the NPS conf folder here, then modify the nps.conf file. web_username=admin web_password=123 You can change your login information by changing the above parameter. Once you're done, you can upload the conf folder to your VPS directory.
docker run -d --name nps --net=host -v <your vps conf folder directory>:/conf ffdfgdfg/nps
Like in this tutorial, I upload the conf folder to the /home/centos folder, then <my vps conf folder directory> will be /home/centos/conf
Once the nps started, you can access the web panel by entering your VPS IP:8080. Now, you can config and connect your client here.