Skip to content

rcdevgames/simple-tunnel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSH Tunnel

A simple SSH tunneling application written in Go.

Features

  • Configuration via JSON file
  • SSH authentication with username/password or private key
  • Source and destination port configuration for tunneling
  • No interactive shell access
  • Optional configuration encryption

Installation

  1. Make sure you have Go installed (version 1.21 or later)
  2. Clone this repository
  3. Run go build to build the application

Usage

./tunnel.exe -config config.json

Configuration

The application uses a JSON configuration file with the following structure:

{
  "ssh": {
    "host": "example.com",
    "port": 22,
    "username": "user",
    "password": "password",
    "private_key": ""
  },
  "tunnel": {
    "source_port": 8080,
    "destination_port": 3306
  },
  "encrypted": false
}

SSH Configuration

  • host: The SSH server hostname or IP address
  • port: The SSH server port (usually 22)
  • username: SSH username
  • password: SSH password (optional if using private key)
  • private_key: SSH private key file path or private key content (optional if using password)

If you specify a file path for private_key (e.g., "./id_rsa"), the application will read the private key from that file. If you specify the actual private key content (e.g., "-----BEGIN RSA PRIVATE KEY-----..."), the application will use it directly.

Tunnel Configuration

  • source_port: The local port to listen on
  • destination_port: The remote port to connect to

Encryption

  • encrypted: Whether the configuration file is encrypted

Encryption

To create an encrypted configuration file, set encrypted to true in the configuration and use the saveConfig function to save it.

Note: The current implementation uses a fixed encryption key for simplicity. In a production environment, you should use a more secure method for managing encryption keys.

Example

To tunnel localhost:8080 to a remote MySQL server running on port 3306:

{
  "ssh": {
    "host": "remote-server.com",
    "port": 22,
    "username": "myuser",
    "password": "mypassword"
  },
  "tunnel": {
    "source_port": 8080,
    "destination_port": 3306
  },
  "encrypted": false
}

Then run:

./tunnel.exe -config config.json

This will forward all connections to localhost:8080 through the SSH server to remote-server.com:3306.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages