What is Serveo

Serveo, It is a free network service penetration, Serveothe local computer may be exposed on the Internet, the official claim that it is Ngrokan excellent alternative.

ServeoIts biggest advantage is to use existing SSHclient, without installing any client software, to complete the port forwarding.

ServeoWorks is simple: when a user SSH is connected to Serveotime will establish a remote agent with the site, Serveowhich will then generate a public URL, anyone can use this URL to access your local computer.

Project address: https://serveo.net

Use Serveo

ServeoVery simple to use, only you need to use SSH a client and can connect to any Internet system will do. For example: Linux, Windows, MacOS and other systems, even if it is Android, iOS there is no problem. Let’s look at a few of the most common use cases:

  1. Open local service to public network

Map the 8080 port of a local application to the public network.

    1. # if redirect to other port,just change port number

 

    1. $ ssh -R 80:localhost:8080 serveo.net

 

    1. Hi there

 

    1. Forwarding HTTP traffic from https://heryum.serveo.net

 

    1. Press g to start a GUI session and ctrl-c to quit.

 

 

SSH, After successful connection, randomly generates a serveo.net second-level domain. Then you can use the browser to access the secondary domain name randomly generated her yum.serveo.net indirect access to services on the local computer 8080 port.

SSH When you first establish a connection with a new server, you will be prompted to select yes directly.

If you don’t want to use a random domain name, it is okay to specify a fixed second-level domain name.

    1. # example  ywzm.serveo.net,change it for yourself

 

    1. $ ssh -R ywzm:80:localhost:8080 serveo.net

 

    1. Hi there

 

    1. Forwarding HTTP traffic from https://ywzm.serveo.net

 

    1. Press g to start a GUI session and ctrl-c to quit.

 

 

 

 

    1. $ ssh -R ywzm.serveo.net:80:localhost:8080 serveo.net

 

 

SSH After a successful connection, then you can use the public Internet ywzm.serveo.net access to your local computer services of the port 8080.

In the above example, we are forwarding HTTP service. If you need to forward a TCP service, and how to do it? In fact, the method is also very simple, just set the forwarding port and local port of the public network. For example:  we need to forward the local 3306 port to the public network, use the following command.

    1. # internet port 1492

 

    1. $ ssh -R 1492:localhost:3306 serveo.net

 

 

 

    1. # if port=0,the random port is used

 

    1. $ ssh -R 0:localhost:3306 serveo.net

 

 

  1. Redirect local SSH to the public network

In many scenes, we need remote access to a local computer SSHs ervice. To achieve such a requirement is also very simple, just use the following command.

    1. # name

 

    1. $ ssh -R myhost:22:localhost:22 serveo.net

 

    1. Hi there

 

    1. Forwarding SSH traffic from alias “myhost”

 

    1. Press g to start a GUI session and ctrl-c to quit.

 

 

 

After a successful connection, then you can on this computer within the network from the public Internet SSHaccess a.

    1. $ ssh -J serveo.net myuser@myhost

 

    1. Hi there

 

    1. myuser@myhost’s password:

 

    1. Last login: Mon Dec 24 21:00:32 2019 from 127.0.0.1

 

 

 

-JOptions in the OpenSSH 7.3version introduced only if you use a SSH client older version, you can use ProxyCommandoptions instead.

$ ssh -o ProxyCommand="ssh -W myhost:22 serveo.net" user@myhost

Some other tips

  1. Keep SSH connections from timeout

As we all know, SSH once the connection times out, it will automatically disconnect, which will easily cause service interruption. Here we only need to SSH connect an additional keep-alive parameters -o ServerAliveInterval=60on it.

    1. # every 60 seconds keep alive

 

    1. $ ssh -o ServerAliveInterval=60 -R 80:localhost:8080 serveo.net

 

  1. Guarding SSH connections

Although the above method can solve the problem of timeout, the process is always running in the foreground. To solve this problem, the official recommended AutoSSHto process guard.

AutoSSHOne pair is used SSHto connect the monitor can automatically reconnect in the event of network problems or procedural issues, in order to achieve long-term SSHpurpose of stabilizing the connection.

  • Install AutoSSH
    1. # Debian / Ubuntu OS

 

    1. $ apt install autossh -y

 

 

 

    1. # CentOS / RHEL OS

 

    1. $ yum install autossh -y

 

 

  • Add AutoSSH to the system service

Here to add to the Systemdsystem services, for example, this method is suitable for CentOS 7, Debian 8, Ubuntu 16and above system version. First, we create a Systemd service for AutoSSH.

    1. $ cat > /etc/systemd/system/autossh.service <<EOF

 

    1. [Unit]

 

    1. Description=autossh

 

    1. After=network.target

 

 

 

    1. [Service]

 

    1. Type=simple

 

    1. Environment=”AUTOSSH_GATETIME=0″

 

    1. ExecStart=$(command -v autossh) -M 0 -o “ServerAliveInterval 60” -o “ServerAliveCountMax 3” -R 80:localhost:8080 serveo.net

 

    1. Restart=on-abort

 

 

 

    1. [Install]

 

    1. WantedBy=multi-user.target

 

    1. EOF

 

 

AutoSSH ,The -M, main parameters used to specify a listening port to monitor the SSH connection state, where 0 specifies the primary purpose is to disable AutoSSHthe monitoring ports. Keep alive still use SSHtheir own ServerAliveIntervaland the ServerAliveCountMaxoption to complete.

Secondly, Systemdthe system service is created, we start the AutoSSHservice and set to boot from Kai.

    1. $ systemctl start autossh

 

    1. $ systemctl enable autossh

 

 

  1. If you can’t connect to Serveo via port 22, the official 443 port is reserved for you.
$ ssh -p 443 -R 80:localhost:8080 serveo.net
  1. Use a custom domain name / subdomain

By default, we are all used Serveoto generate second-level domain for connection. If you want to use your own domain name is also possible, the method is very simple. Just add an A record and a TXT record to the DNS of your domain name.

4.1 Add an A record

A | serveo | 159.89.214.31

4.2 Add a TXT record

TXT | serveo | authkeyfp=SHA256:pmc7ZRv7ymCmghUwHoJWEm5ToSTd33ryeDeps5RnfRY

authkeyfpWith the back of a string of characters that is RSAkey fingerprint, you can use the ssh-keygen -lcommand to view it.

Once the DNS resolution record has been added, you can connect using a custom domain name.

$ ssh -R serveo.ywzm.org:80:localhost:3000 serveo.net

At this point, Serveothe basic usage is complete. If you have more interest in it, please go to the official website to explore.

Reference document

  1. Https:/www.google.com
  2. Https://www.moerats.com/archives/990/
  3. Https://blog.rxliuli.com/p/5ad7fa84/
  4. Https://www.jianshu.com/p/d0b3991a9ce1
  5. Https://blog.csdn.net/kongxx/article/details/86178364
  6. Https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-autossh/