{"id":283,"date":"2019-11-05T14:14:58","date_gmt":"2019-11-05T14:14:58","guid":{"rendered":"http:\/\/blog.davcloud.top\/?p=283"},"modified":"2019-11-08T14:55:59","modified_gmt":"2019-11-08T14:55:59","slug":"build-ssh-proxy-server-on-vps","status":"publish","type":"post","link":"https:\/\/blog.davcloud.top\/?p=283","title":{"rendered":"Build ssh proxy server on VPS"},"content":{"rendered":"\n<h2>Abstract<\/h2>\n\n\n\n<p>This article aims to build a SSH proxy server with a VPS with public IP address, and we will use a China VPS as example to access Chinese only website by the ssh proxy. This method can used to access website in GFW from China as well.<\/p>\n\n\n\n<h2>Requirement<\/h2>\n\n\n\n<ol><li>A Chinese VPS with public IP address, CentOS 7 as example.<\/li><li>A SSH client on the PC, such as Git for Windows on Windows.<\/li><\/ol>\n\n\n\n<h2>Step 1. Buying a Chinese VPS<\/h2>\n\n\n\n<p>Buying a Chinese VPS with public IP address so that you have a Chinese IP address to access the Chinese only service.<\/p>\n\n\n\n<h2>Step 2. Install SSH client<\/h2>\n\n\n\n<p>Install SSH client like Git for Windows. If you use mac or linux, you can just use terminal.<\/p>\n\n\n\n<h2>Step 3. Generate SSH public key<\/h2>\n\n\n\n<p>To allow device use the VPS as proxy, generate a SSH public key of the device and add it to the allow list of SSH on the VPS.<\/p>\n\n\n\n<p>Generate SSH public key with Git Bash with this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-keygen<\/code><\/pre>\n\n\n\n<p>Then the public key will be found in the file as the command windows returned. It is usually in the path C:\/User\/Username\/.ssh\/id_rsa.pub<\/p>\n\n\n\n<h2>Step 4. Copy the SSH public to the allow list of SSH on VPS<\/h2>\n\n\n\n<p>Log in to the VPS, and open the file \/root\/.ssh\/authorzied_keys:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vim \/root\/.ssh\/authorzied_keys<\/code><\/pre>\n\n\n\n<p>Add the SSH public key generated on the computer to the end of the file, and save the file.<\/p>\n\n\n\n<h2>Step 5. Build port map<\/h2>\n\n\n\n<p>In the Git Bash on the PC, build port map with this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -Nf -D 7777 username@remote_server<\/code><\/pre>\n\n\n\n<p>It means forward access traffic to the local port 7777, and the <em><code>username<\/code><\/em> and <em><code>remote_server<\/code><\/em> is the login information of the VPS.<\/p>\n\n\n\n<p>Now, 127.0.0.1:7777 is a proxy on your PC, which can forward access traffic to the VPS server.<\/p>\n\n\n\n<h2>Step 6. Set proxy on Chrome<\/h2>\n\n\n\n<p>We use Chrome and SwitchyOmega plugin as an example to set the proxy. Add a new scene mode in the left sidebar, and add a proxy server with parameter as below:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" width=\"890\" height=\"66\" src=\"https:\/\/blog.davcloud.top\/wp-content\/uploads\/2019\/11\/image-3.png\" alt=\"\" class=\"wp-image-299\" srcset=\"https:\/\/blog.davcloud.top\/wp-content\/uploads\/2019\/11\/image-3.png 890w, https:\/\/blog.davcloud.top\/wp-content\/uploads\/2019\/11\/image-3-300x22.png 300w, https:\/\/blog.davcloud.top\/wp-content\/uploads\/2019\/11\/image-3-768x57.png 768w\" sizes=\"(max-width: 890px) 100vw, 890px\" \/><\/figure><\/div>\n\n\n\n<p>Apply the settings and turn on the SwitchyOmega when access to the Chinese only service with Chrome, then the service can be accessed successfully.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Abstract This article aims to build a SSH proxy server with a VPS with public IP address, and we will use a China VPS as example to access Chinese only website by the ssh proxy. This method can used to access website in GFW from China as well. Requirement A Chinese VPS with public IP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[111,110],"_links":{"self":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/283"}],"collection":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283"}],"version-history":[{"count":18,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions"}],"predecessor-version":[{"id":409,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions\/409"}],"wp:attachment":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}