Use Alibaba Cloud server and frp for intranet penetration to realize remote access to intranet ip server

Through the ssh protocol, I use a laptop to remotely control my desktop host (ubuntu18.04) as a server to run the program. Since the desktop is not a public network ip, and the two machines are not a network segment, it cannot be connected through the ssh protocol. Therefore, through the use of FRP intranet penetration, by renting an Alibaba Cloud server (centos7.3), obtaining the public network IP and port mapping, so that we can access our desktop host.

The first step is to install mobaxterm, a very easy to use all-round terminal artifact. Attach the download link: https://mobaxterm.mobatek.net/download.html
Click to select the free version:
Note: Both the client and server need to install mobaxterm, that is, laptop and desktop host.
Insert picture description here
Click to select the portable version:
Insert picture description here
After downloading, unzip and install.

Next, we need a public IP address. Here, I suggest that you can go to the student area of ​​Alibaba Cloud Server for student certification. You can rent a lightweight server for 10 yuan a month, and attach the link:
https://developer. aliyun.com/plan/grow-up?utm_content=se_1007159595

Choose the first one, 9.5 month server
Insert picture description here

After purchasing the server, we can log in to our console and select the lightweight server we just purchased (centos7.3 is recommended when initializing the system image).
Insert picture description here
The IP address here is the server with public IP provided by Alibaba Cloud.
Click to enter the server control page, click remote connection, we can enter a server password, this password is used to connect to the server at the beginning, in the back, for the security of the server, to prevent someone from brute force cracking, we can log in with the key and disable the password . However, it is currently recommended to set a password first.
Insert picture description here

After setting the password, we need to click on the firewall column, click Modify, and open two ports. I chose 7000 and 6000 for port mapping.
Insert picture description here

Now that we have the public network ip and port, we need to perform intranet penetration.

Here we are using open source on github a big brother frp project, attach links:
https://github.com/fatedier/frp
frp download link: https: //github.com/fatedier/frp/releases
according to For your own system, select the corresponding version.
Note: frp needs to run on the Alibaba Cloud server and the desktop host that you want to use as the server, so after we download frp, we need to run on the Alibaba Cloud server and our desktop host Unzip them separately.
Insert picture description here
Specific steps:
1. First log on to our Alibaba Cloud server
through mobaxterm. Click session on mobaxterm and select ssh. Insert picture description here
2. Then, remote host enter the public network ip of your Alibaba Cloud server, specify username enter root, port enter Alibaba Cloud The ssh port, port 22.
Insert picture description here
After entering, it will be displayed as shown below:
Insert picture description here
3. This is the command line interface of centos7.3. We can download the frp compressed package just now on github, and then pull it to the /root/ folder on the left to compress it, or Command operations are performed in the terminal on the right.

$wget https://github.com/fatedier/frp/releases/download/v0.34.2/frp_0.34.2_linux_amd64.tar.gz
$tar -xzvf frp_0.34.2_linux_amd64.tar.gz

After the decompression is complete, a frp folder will appear under the root folder (it may be named frp_0.34.2xxx, just rename it to frp), click in, you will see a bunch of configuration files, in Alibaba Cloud On the server side, we only need to modify the frps.ini configuration file, modify the content as follows, save and exit.
Insert picture description here
On our desktop host, that is, the host that needs to be accessed, download and decompress frp as well, click to enter the decompressed folder, and modify the frpc.ini configuration file as follows:
Insert picture description here
server_addr is your own public network ip
server_port is modified to frpc.ini The bind_port modified in: 7000
remote_port is modified to another port that you open. This port is also the port for you to remotely access your host. I set 6000.
The remaining parameters can be consistent with the above figure.
Note that these ports must be opened on the Alibaba Cloud firewall before they can be used.

Okay, now that all the configuration is complete, we can penetrate the intranet and connect remotely.
First, we enter the Alibaba Cloud server just now through mobaxterm (remember to enter the Alibaba Cloud server and select port 22), cd to the folder where our frps.ini is located on the command line, and enter the command:

./frps

Then go to our ubuntu desktop host, also cd to the frp folder, type in the command line

./frpc

Both of these commands will prompt for success. If there is no success, it is recommended to check whether the port and ssh protocol service are installed.
Finally, on our laptop, which is the machine that needs remote access, open mobaxterm and select new session. Similarly, enter Alibaba Cloud’s public network ip, pay attention to specify name, remember to fill in your host account name, and port select you in frpc The remote_port configured in .ini, mine is 6000, and then enter your password as required to enter the host, so as to realize the remote connection of different network segments and intranet hosts.
Insert picture description here
This is the page after the connection:
Insert picture description here
through the mobaxterm terminal, you can see all the folders on our host and perform a series of terminal operations.
Note: Before configuring intranet penetration, we must check whether the ssh protocol service is installed on our host! ! ! Although the linux system seems to have its own ssh protocol, it may be deleted by mistake because of some remove instructions. Remember.

Finally, for the security of the server, I suggest to configure the public key key on the Alibaba Cloud server and the host server, and disable the password. The laptop can log in to the server through the key. The specific tutorial will be released later.

Guess you like

Origin blog.csdn.net/Zzzzybfly/article/details/109638361