Skip to content

Instantly share code, notes, and snippets.

@format37
Created February 21, 2025 13:28
Show Gist options
  • Save format37/782861851d05b8adc921205d511cb9ee to your computer and use it in GitHub Desktop.
Save format37/782861851d05b8adc921205d511cb9ee to your computer and use it in GitHub Desktop.
ngrok ssh

How to serve ssh using Ngrok

  1. Install ssh and define user
# Update system and install SSH server
sudo apt update
sudo apt install openssh-server

# Check SSH service status
sudo systemctl status ssh

# Create new user
sudo adduser alex
# During this step you'll be prompted to:
# - Set and confirm password
# - Fill in optional user information (you can press Enter to skip)

# Add user to sudo group
sudo usermod -aG sudo alex

# Edit SSH configuration to allow password authentication
sudo nano /etc/ssh/sshd_config
# Make sure these lines are set:
# PasswordAuthentication yes
# PermitRootLogin yes

# Restart SSH service
sudo systemctl restart sshd
  1. Install ngrok
sudo snap install ngrok
  1. Run ngrok tcp server Generate your token on the ngrok dashboard
ngrok authtoken <YOUR_AUTH_TOKEN>
ngrok tcp 22

You should see something like

Session Status                online                                                                                           
Account                       Alex (Plan: Free)                                                                                
Version                       3.20.0                                                                                           
Region                        Europe (eu)                                                                                      
Latency                       64ms                                                                                             
Web Interface                 http://127.0.0.1:4040                                                                            
Forwarding                    tcp://0.tcp.eu.ngrok.io:14712 -> localhost:22                                                    
                                                                                                                               
Connections                   ttl     opn     rt1     rt5     p50     p90                                                      
                              2       0       0.00    0.00    8.06    9.72 
  1. To connect from remote machine
    Copy the Forwarding value and run:
ssh [email protected] -p 14712

You neet to input the password that you have defined for the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment