Giter VIP home page Giter VIP logo

loco's Introduction

Loco

Build Status PyPI PyPI

Share localhost through SSH. Making local/remote port forwarding easy and safe.

Story

sender wants to share his web app hosted at port 52222. receiver wants to see what the app is all about.

  • receiver runs loco pubkey to copy their public SSH key to clipboard
  • receiver sends pubkey to sender by chat, mail or pigeon.
  • sender runs loco create "RECEIVER_PUBKEY". This is the interesting part!
  • receiver runs loco listen SENDER, where sender is ssh config such as user@ip

Receiver can now see what sender is seeing at localhost:52222

When you are behind a (company) firewall/router, then there are 3 possible solutions.

  • You can use a "shared" area (such as a cloud instance).
  • You can do remote forwarding instead of local forwarding. Basically, as long as 1 of the 2 parties is not within a firewall, it'll work.
  • You can open up port 22 (SSH).

Features

  • Convenience. Share whatever is happening on your localhost with someone else
  • Safety. Nothing beats SSH. The only open port required is 22. Share your HTTP through SSH!
  • Containment. Specifically creates an SSH user that can ONLY do port forwarding; nothing else.
  • Cross-platform. Works on OSX and Linux in general.
  • No 3rd party. Unlike ngrok, you won't need to rely on a third party.

Installation

Works using both Python 2.7+ and Python 3+:

pip install loco

Functionality

# cast your localhost to someone else
loco cast RECEIVER

# No need to keep a terminal open
loco listen SENDER --background

# Kills a `loco listen` in the background
loco kill [optional: PORT, default=52222]

# Remove all settings for a user (by default loco0).
loco remove_user

# View how you can be accessed
loco ls # outputs
user="loco0" port=52222 ssh_key=AAAAB3NzaC ..... joCyayMg+d account="pascal@T510"

# Create specific user+port combination (don't forget to share this info with buddy)
# And don't forget the quotes
loco create "PUBKEY" loco5@someip --port 5000

# NOTE: default is to serve at same as remote/local, need to give 1
loco listen loco5@someip --remote_port 5000

# push your content to someone who created a loco user for you
loco cast loco5@someip --local_port 5000

# --expose exposes `listen` or `cast` to 0.0.0.0
# requires ssh to accept casting, i.e.:
# 'GatewayPorts yes' in '/etc/ssh/sshd_config'
loco cast loco5@someip --expose

For issues, such as both parties being within a firewall, you can use a server in between (e.g. some cloud instance). If just one party is within firewall, then you can use either cast/listen.

In case of using an inbetween server:

# on server:
loco create "PUBKEY_RECEIVER"
loco create "PUBKEY_SENDER"
# on sender:
loco cast loco0@server
# on receiver
loco listen loco0@server

The interesting part

loco create creates a restricted user on the senders' machine. This user (by default called loco0) can do nothing except for allow port forwarding at a given port (by default 52222). The receiver can use loco listen SENDER_IP to use SSH for portforwarding (again by default as loco0, port 52222). The good thing is that you can now safely make a HTTP connection without allowing this user to do anything else. Note that everything can be configured; the used username, the senders' port to be shared, and on which port it will be receivable by the receiver.

To find out more possibilities, you can use --help using the CLI:

pascal@MBP:~ $ loco listen --help
Usage: loco listen [OPTIONS] HOST

  Listen on a remote localhost port and serve it locally.

  Provide host.

 Example: loco listen USER@IP

Options:
  -b, --background
  --local_port INTEGER
  --remote_port INTEGER
  --browse TEXT
  --help                 Show this message and exit.

You will have complete control over whether you want to allow sharing a single port with many users, or each user their own port.

loco users are special

Any username starting with "loco" will be considered a loco user. Apart from being restricted, the CLI tool also takes extra care for loco users. For example, it will warn you when you would try to remove non loco users. It will throw an exception when you try to delete yourself. loco ls also only lists the loco users.

Contributing

Feel free to make suggestions.

loco's People

Contributors

kootenpv 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

loco's Issues

loco remove-user throwing an exception

loco remove-user throwing an exception

I get this error stack:
$ loco remove-user loco0
Traceback (most recent call last):
File "/home/ec2-user/.local/bin/loco", line 8, in
sys.exit(main())
File "/home/ec2-user/.local/lib/python3.7/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/home/ec2-user/.local/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/ec2-user/.local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/ec2-user/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/ec2-user/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/ec2-user/.local/lib/python3.7/site-packages/loco/loco.py", line 136, in remove_user
donotrun(remove_user_fn, user)
NameError: name 'donotrun' is not defined

Looks like the error comes from this function: donotrun is not defined

@main.command()
@click.argument("user", default=USER)
def remove_user(user):
""" Used to remove a loco user """
if user in os.path.expanduser("~"):
raise Exception("Cannot delete self")
if not user.startswith("loco"):
inp = input("Are you sure you want to delete user '{}' [y/N]: ".format(user))
if inp.lower() != "y":
print("Aborting.")
return
os_dependent_functions = {"Darwin": remove_user_osx, "Linux": remove_user_linux}
remove_user_fn = platform_fn(**os_dependent_functions)
donotrun(remove_user_fn, user)

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.