Coder Social home page Coder Social logo

ferama / rospo Goto Github PK

View Code? Open in Web Editor NEW
279.0 9.0 24.0 15.69 MB

🐸 Simple, reliable, persistent ssh tunnels with embedded ssh server

License: MIT License

Go 98.74% Shell 0.77% Dockerfile 0.50%
ssh ssh-tunnels golang reverse-shell port-forwarding ssh-server embedded-sshd-server devtools developer-tools networking

rospo's Introduction

Go Reference Go Report Card

Rospo is a tool meant to create secure and reliable SSH tunnels. A single binary includes both client and server. It's meant to make SSH tunnels fun and understandable again

Table of Contents

  1. Features
  2. How to Install
  3. Quick command line usage
  4. Example Scenarios

Features

  • Easy to use (single binary client/server functionalities)
  • Encrypted connections through ssh ( crypto/ssh package )
  • Automatic connection monitoring to keep it always up
  • Embedded sshd server
  • Forward and reverse tunnels support
  • JumpHosts support
  • Command line options or human readable yaml config file
  • Run as a Windows Service support
  • Pty on Windows through conpty apis
  • Sftp subsystem support server side
  • File transfer support client side (get and put sftp subcommands)
  • SOCKS5/SOCKS4 proxy server trough SSH

How to Install

Rospo actually full supports *nix oses and Windows 10+

macOS

Homebrew

Install rospo using Homebrew

brew install rospo

GNU/Linux

Binary Download

Platform Architecture URL
GNU/Linux amd64 https://github.com/ferama/rospo/releases/latest/download/rospo-linux-amd64
arm64 https://github.com/ferama/rospo/releases/latest/download/rospo-linux-arm64
arm https://github.com/ferama/rospo/releases/latest/download/rospo-linux-arm

Microsoft Windows

Binary Download

Platform Architecture URL
Microsoft Windows amd64 https://github.com/ferama/rospo/releases/latest/download/rospo-windows-amd64.exe

Docker Container

You can use the docker ditribution where useful/needed

docker run ghcr.io/ferama/rospo --help

Quick command line usage

Rospo supports keys based auth and password auth. Keys based one is always the preferred, so it is better if identity, authorized_keys etc are always correctly setup.

Usage example:

Starts an embedded ssh server and reverse proxy the port (2222 by default) to remote_server

$ rospo revshell user@server:port

Forwards the local 5000 port to the remote 6000 on the remote_server

$ rospo tun forward -l :5000 -r :6000 user@server:port

Get more detailed help on each command runnig

$ rospo tun forward --help
$ rospo tun reverse --help
$ rospo sshd --help

For more complex use cases and more options, you can use a config file

$ rospo run config.yaml

Look at the config_template.yaml for all the available options.

Scenarios

Example scenario: Windows reverse shell

Why use an embedded sshd server you might ask me. Suppose you have a Windows WSL instance that you want to access remotely without complicated setups on firewalls and other hassles and annoyances. With rospo you can do it in ONE simple step:

$ rospo revshell remote_ssh_server

This command will run an embedded sshd server on your wsl instance and reverse proxy its port to the remote_ssh_server

The only assumption here is that you have access to remote_ssh_server. The command will open a socket (on port 2222 by default) into remote_ssh_server that you can use to log back to WSL using a standard ssh client with a command like:

$ ssh -p 2222 localhost

Or even better (why not!) with rospo you can reverse proxy a powershell. Using rospo for windows:

rospo.exe revshell remote_ssh_server

Example scenario: Windows service

Rospo support execution as a service on windows. This means that you can create a persistent tunnel that can be installed as a service and started automatically with the machine.

Let's do this with the Windows Remote Desktop service.

Create a rospo conf file like this:

sshclient:
  server: your-rospo-or-sshd-server-uri:2222
  identity: "c:\\absolute_path_to_your\\id_rsa"
  known_hosts: "C:\\absolute_path_to_your\\known_hosts"

tunnel:
  - remote: :3389
    local: :3389  # the windows remote desktop port
    forward: false

Launch a terminal (powershell) with Administrative rights. You can then perform the following actions:

# create the rospo service
sc.exe create rospo start= auto DisplayName= Rospo binpath= "C:\rospo.exe run C:\conf.yaml"

# start service
sc.exe start rospo

# query service status
sc.exe query rospo

# stop and delete the service
sc.exe stop rospo; sc.exe delete rospo

Example scenario: multiple complex tunnels

Rospo supports multiple tunnels on the same ssh connetion. To exploit the full power of rospo for more complex cases, you should/need to use a scenario config file. Let's define one. Create a file named config.yaml with the following contents

sshclient:
  server: myuser@remote_server_address
  identity: "~/.ssh/id_rsa"
  jump_hosts:
    - uri: anotheruser@jumphost_address
      identity: "~/.ssh/id_rsa"

tunnel:
  - remote: ":8000"
    local: ":8000"
    forward: yes
  - remote: ":9999"
    local: ":9999"
    forward: yes
  - remote: ":5000"
    local: ":5000"
    forward: no
    # use custom sshclient for this tunnel
    sshclient:
      server: myuser@another_server
      identity: "~/another_identity"

# starts a socks proxy ...
socksproxy:
  listen_address: :1080
  # ...using a dedicated client
  sshclient:
    server: localhost:9999

Launch rospo using the config file instead of the cli parameters:

$ rospo run config.yaml

What's happens here is that rospo will connect to remote_server_address through the jumphost_address server and will:

  1. open a socket on the local machine listening on port 8000 that forwards all the traffic to the service listening on port 8000 on the remote_server_address machine
  2. open a socket on the local machine listening on port 9999 that forwards all the traffic to the service listening on port 9999 on the remote_server_address machine
  3. open a socket on the remote machine listening on port 5000 that forwards all the traffic from remote machine to a local service (on the local machine) listening on port 5000

But these are just an examples. Rospo can do a lot more.

Tunnels are fully secured using standard ssh mechanisms. Rospo will generate server identity file on first run and uses standard authorized_keys and user known_hosts files.

Rospo tunnel are monitored and kept up in the event of network issues.

rospo's People

Contributors

ceclin avatar dependabot[bot] avatar ferama avatar icholy avatar lars18th avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rospo's Issues

user.Current may return err in some cases on Windows

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x40 pc=0xae5ea2]

goroutine 1 [running]:
github.com/ferama/rospo/cmd.init.1()
        github.com/ferama/rospo/cmd/grabpubkey.go:15 +0x62

golang/go#37348

I think it is better to use os.Getwd or empty string as a fallback.

[INFO] ssh with username and password

I used to do something like this for forwarding ssh ports
ssh -R 2000:localhost:3000 [email protected]
and enter password in command prompt

how can i do this with rospo, i tried revshell including "-i" option but it expects authorized keys
I want to login with username and password. Is it possible to do this with rospos? if yes can you share the steps.

Question: Persistent tunnel?

Hi,

I want to know if rospo can work like autossh. That's executing in a loop maintainning a persistent SSH tunnel.

Please, could you clarify this?
Thank you.

Question: webui ?

Hi @ferama ,

From this code:

rospo/pkg/web/web.go

Lines 13 to 14 in af1bc6f

// StartServer start the rospo web server. The webserver
// exposes rospo apis and a nice ui at the /

I assume that a simple http://127.0.0.1:8090/ will get a "nice UI". However, any GET to "/" responses with a 404 Error. I can only obtain responses using the API with /api/tuns, /api/stats and /api/info. Please could you document the webui more?

Thank you.

some questions

Hi, I was testing rospo and had some questions:

  • Are keys that are password protected not supported? I get an error "unable to authenticate" when trying to use a password protected key.
  • Is there a way to provide the server password as a command line arg?
  • How do you launch the UI?

v0.11.6 Running bugs on Windows platforms?

Using the official version of rospo-windows-amd64.exe 0.11.6 latest version, running it on individual Windows 7 systems may result in errors:
[fatal error: kernel32.DLL not found]
[Runtime: panic before malloc heap initialized]

But if you download the source code and use go 1.20.12 to compile the generated Win64 program, it will work normally. Did the official use any parameters during compilation?

Add support for MIPS devices

Hi,

I tested to compile rospo for OpenWRT devices, and it works!
So I suggest to add these targets inside the build.sh script:

### multi arch binary build
GOOS=linux GOMIPS=softfloat GOARCH=mips build
GOOS=linux GOMIPS=softfloat GOARCH=mipsle build

Regards.

HTTP error 408 on initial connection

I am serving a simple Node JS app on windows machine, then tunnel those port on public server. When accessing those port, it is showing HTTP error 408 initially, but success on subsequent request.

~# wget "http://127.0.0.1:30005/"
--2023-09-21 10:17:14--  http://127.0.0.1:30005/
Connecting to 127.0.0.1:30005... connected.
HTTP request sent, awaiting response... 408 Request Timeout
2023-09-21 10:17:14 ERROR 408: Request Timeout.

~# wget "http://127.0.0.1:30005/"
--2023-09-21 10:17:17--  http://127.0.0.1:30005/
Connecting to 127.0.0.1:30005... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23 [text/html]
Saving to: ‘index.html.1’

index.html.1        100%[===================>]      23  --.-KB/s    in 0s

2023-09-21 10:17:17 (3.38 MB/s) - ‘index.html.1’ saved [23/23]

IPv6 not supported in parseSSHUrl

I use rospo tun forward on my windows laptop to forward a port to remote android device. But it doesn't work and I don't know why.
If I use rospo tun forward on wsl, it works. If I use rospo tun forward on wsl and connect from my windows, it doesn't work too.

I don't know whether it is my error or some bug in rospo.

Reverse tunnel question

Hi

I'm trying to get workig rospo as a reverse tunnel to listening on the remote side on other than localhost:
rospo tun reverse -l 127.0.0.1:19898 -r 10.10.10.10:29898 [email protected]:22

It's working with autossh, but with rospo it listening only on 127.0.0.1:29898

What am I missing ?
Thanks
Levi

Run command doesn't respect jump_hosts settings

If you run rospo with the following yaml:

# the ssh client configuration
sshclient:
  # OPTIONAL: private key path. Default to ~/.ssh/id_rsa
  identity: "~/.ssh/id_ed25519"
  # REQUIRED: server url
  server: [email protected]:8001
  # OPTIONAL: Known hosts file path. Ignored if insecure is set to true
  known_hosts: "~/.ssh/known_hosts"
  # OPTIONAL: if the check against know_hosts is enabled or not
  # default insecure false
  insecure: false
  # OPTIONAL: list of jump hosts hop to traverse
  # comment the section for a direct connection
  jump_hosts:
    - uri: [email protected]:8000
      # OPTIONAL: private key path. Default to ~/.ssh/id_rsa
      identity: "~/.ssh/another_id_ed25519"

It will connect to port 8000 with ~/.ssh/id_ed25519, but the identity should be ~/.ssh/another_id_ed25519.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.