telebit.js/README.md

14 KiB

Telebit™ Remote

Because friends don't let friends localhost™

| Sponsored by ppl | Telebit Remote | Telebit Relay |

Break out of localhost.

If you need to get bits from here to there, Telebit gets the job done.

Install Telebit Remote on any device - your laptop, raspberry pi, whatever - and now you can access that device from anywhere, even securely in a web browser.

How does it work? It's a net server that uses a relay to allow multiplexed incoming connections on any external port.

Features

  • Show your mom the web app you're working on
  • Access your Raspberry Pi from behind a firewall
  • Watch Netflix without region restrictions while traveling
  • SSH over HTTPS on networks with restricted ports or protocols
  • Access your wife's laptop while she's on a flight

Examples

As a user service

telebitd --config ~/.config/telebit/telebitd.yml &

As a system service

sudo telebitd --config ~/.config/telebit/telebitd.yml

Example output:

Connect to your device by any of the following means:

SSH+HTTPS
        ssh+https://lucky-duck-37.telebit.cloud:443
        ex: ssh -o ProxyCommand='openssl s_client -connect %h:%p -servername %h -quiet' lucky-duck-37.telebit.cloud -p 443

SSH
        ssh://ssh.telebit.cloud:32852
        ex: ssh ssh.telebit.cloud -p 32852

TCP
        tcp://tcp.telebit.cloud:32852
        ex: netcat tcp.telebit.cloud 32852

HTTPS
        https://lucky-duck-37.telebit.cloud
        ex: curl https://lucky-duck-37.telebit.cloud
# Forward all https traffic to port 3000
telebit http 3000

# Forward all tcp traffic to port 5050
telebit tcp 5050

# List all rules
telebit list

Install

Mac & Linux

Open Terminal and run this install script:

curl -fsSL https://get.telebit.cloud | bash

What does the installer do?

  • install Telebit Remote to /opt/telebit
  • symlink the executables to /usr/local/bin for convenience
    • /usr/local/bin/telebitd => /opt/telebit/bin/telebitd
    • /usr/local/bin/telebit => /opt/telebit/bin/telebit
  • create the appropriate system launcher file
    • /etc/systemd/system/telebit.service
    • /Library/LaunchDaemons/cloud.telebit.remote.plist
  • create local user config
    • ~/.config/telebit/telebit.yml
    • ~/.local/share/telebit

Of course, feel free to inspect it before you run it: curl -fsSL https://get.telebit.cloud

You can customize the installation:

export NODEJS_VER=v10.2
export TELEBIT_PATH=/opt/telebit
export TELEBIT_VERSION=v1              # git tag or branch to install from
curl -fsSL https://get.telebit.cloud/

That will change the bundled version of node.js is bundled with Telebit Relay and the path to which Telebit Relay installs.

You can get rid of the tos + email and server domain name prompts by providing them right away:

curl -fsSL https://get.telebit.cloud/ | bash -- jon@example.com example.com telebit.example.com xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Windows & Node.js

  1. Install node.js
  2. Open Node.js
  3. Run the command npm install -g telebit
  4. Copy the example daemon conifg to your user folder .config/telebit/telebitd.yml (such as /Users/John/.config/telebit/telebitd.yml)
  5. Copy the example remote conifg to your user folder .config/telebit/telebit.yml (such as /Users/John/.config/telebit/telebit.yml)
  6. Change the email address
  7. Run telebitd
  8. Run telebit list

Note: Use node.js v8.x or v10.x

There is a bug in node v9.x that causes telebit to crash.

Remote Usage

# commands
telebit <command>

# domain and port control
telebit <service> <handler> [servername] [options ...]

Examples:

telebit status                          # whether enabled or disabled
telebit enable                          # disallow incoming connections
telebit disable                         # allow incoming connections
telebit restart                         # kill daemon and allow system launcher to restart it

telebit list                            # list rules for servernames and ports

                       ################
                       #     HTTP     #
                       ################

telebit http <handler> [servername] [opts]

telebit http none                       # remove all https handlers
telebit http 3000                       # forward all https traffic to port 3000
telebit http /module/path               # load a node module to handle all https traffic

telebit http none example.com           # remove https handler from example.com
telebit http 3001 example.com           # forward https traffic for example.com to port 3001
telebit http /module/path example.com   # forward https traffic for example.com to port 3001


                       ################
                       #     TCP      #
                       ################

telebit tcp <handler> [servername] [opts]

telebit tcp none                        # remove all tcp handlers
telebit tcp 5050                        # forward all tcp to port 5050
telebit tcp /module/path                # handle all tcp with a node module

telebit tcp none 6565                   # remove tcp handler from external port 6565
telebit tcp 5050 6565                   # forward external port 6565 to local 5050
telebit tcp /module/path 6565           # handle external port 6565 with a node module

telebit ssh disable                     # disable ssh access
telebit ssh 22                          # port-forward all ssh connections to port 22

telebit save                            # save http and tcp configuration changes

Using SSH

SSH over HTTPS

ssh -o ProxyCommand='openssl s_client -connect %h:443 -servername %h -quiet' lucky-duck-42.telebit.cloud

SSH over non-standard port

ssh lucky-duck-42.telebit.cloud -p 3031

Daemon Usage

telebitd --config /opt/telebit/etc/telebitd.yml

Options

/opt/telebit/etc/telebitd.yml:

email: 'jon@example.com'          # must be valid (for certificate recovery and security alerts)
agree_tos: true                   # agree to the Telebit, Greenlock, and Let's Encrypt TOSes
relay: wss://telebit.cloud        # a Telebit Relay instance
community_member: true            # receive infrequent relevant but non-critical updates
telemetry: true                   # contribute to project telemetric data
secret: ''                        # Secret with which to sign Tokens for authorization
#token: ''                         # A signed Token for authorization
ssh_auto: 22                      # forward ssh-looking packets, from any connection, to port 22
servernames:                      # servernames that will be forwarded here
  example.com: {}

Choosing A Relay

You can create a free or paid account at https://telebit.cloud or you can run Telebit Relay open source on a VPS (Vultr, Digital Ocean) or your Raspberry Pi at home (with port-forwarding).

Only connect to Telebit Relays that you trust.

Check Logs

Linux:

sudo journalctl -xefu telebit

macOS:

sudo tail -f /opt/telebit/var/log/info.log
sudo tail -f /opt/telebit/var/log/error.log

Uninstall

Linux:

sudo systemctl disable telebit; sudo systemctl stop telebit
sudo rm -rf /etc/systemd/system/telebit.service /opt/telebit /usr/local/bin/telebit
rm -rf ~/.config/telebit ~/.local/share/telebit

macOS:

sudo launchctl unload -w /Library/LaunchDaemons/cloud.telebit.remote.plist
sudo rm -rf /Library/LaunchDaemons/cloud.telebit.remote.plist /opt/telebit /usr/local/bin/telebit
rm -rf ~/.config/telebit ~/.local/share/telebit

Browser Library

This is implemented with websockets, so you should be able to

LICENSE

Copyright 2016 AJ ONeal