Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Last active May 2, 2023 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilangvperdana/eedaf88b938d23f97f066d6e656fac39 to your computer and use it in GitHub Desktop.
Save gilangvperdana/eedaf88b938d23f97f066d6e656fac39 to your computer and use it in GitHub Desktop.
Cloudflare Tunnel

General

  • Cloudflare build a Zero Trust feature for free to reverse our application (HTTP, TCP, SSH, etc) on-premise to Internet.
  • If you want to try this feature, at least you have a domain and manage it on Cloudflare then go to https://one.dash.cloudflare.com/

SSH

  • Assume you have point your server with agent
  • Assume domain is ssh.endpoint.com
  • For client, we must have an cloudflared tools, we can download from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation/
    • Assume we put cloudflared on /usr/local/bin/ for linux
    • Assume we put cloudflared on D:\ for windows

for Linux

nano /root/.ssh/config

---
Host ssh.endpoint.com
ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h
User root
IdentityFile ~/.ssh/id_rsa
---

for Windows

## for Native Terminal
C:\Users\YourLaptop\.ssh\config

---
Host ssh.endpoint.com
  ProxyCommand D:\WHILE\cloudflared.exe access ssh --hostname %h
  User root
---


## for Putty
fill ssh.endpoint.com on Session then Go to Proxy -> Local -> Add Commandline below

---
D:\cloudflared.exe access ssh --hostname %host
---

## for Winscp
---
D:\\cloudflared.exe access ssh --hostname %host
---

Alternate SSH with Cloudflare Browser Rendering

We can simplify remote our server with GUI Based provided by Cloudflare, you can read more about short-lived certificates.

Reference

TCP

  • Make sure you have set ednpoint with tcp connection on one.dash.cloudflare.com
  • Download cloudflared.exe
  • Execute this
.\cloudflared.exe access tcp --hostname your.site.com --url tcp://localhost:12232
  • localhost:12232 -> our reverse endpoint
  • You can change tcp with udp for your needs.

Connect to Private Network from WARP [Tested by me, it's work!]

We can use WARP to connect to our private subnet network just use WARP from Cloudflare, for reference you can use this :

Alternative

  • You can use Twingate for alternative Zero Trust with Cloudflare
@echo off
set /p connection_type=Insert Connection Type (tcp/udp/ssh):
set /p url_hostname=Insert URL Hostname (without http/https):
set /p reverse_endpoint=Insert Reverse Endpoint (tcp://localhost:123 // udp://localhost:123):
D:\cloudflared.exe access %connection_type% --hostname %url_hostname% --url %reverse_endpoint%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment