• Stars
    star
    105
  • Rank 317,573 (Top 7 %)
  • Language
    Python
  • License
    GNU Affero Genera...
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Share localhost through SSH. Local/Remote port forwarding made safe and easy.

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.

More Repositories

1

whereami

Uses WiFi signals πŸ“Ά and machine learning to predict where you are
Python
5,081
star
2

yagmail

Send email in Python conveniently for gmail using yagmail
Python
2,579
star
3

neural_complete

A neural network trained to help writing neural network code using autocomplete
Python
1,149
star
4

gittyleaks

πŸ’§ Find sensitive information for a git repo
Python
687
star
5

sky

πŸŒ… next generation web crawling using machine intelligence
Python
321
star
6

contractions

Fixes contractions such as `you're` to `you are`
Python
301
star
7

access_points

Scan your WiFi and get access point information and signal quality
Python
181
star
8

textsearch

Find strings/words in text; convenience and C speed πŸŽ†
Python
121
star
9

brightml

Convenient Machine-Learned Auto Brightness (Linux)
Python
119
star
10

shrynk

Using Machine Learning to learn how to Compress ⚑
Python
109
star
11

cliche

Build a simple command-line interface from your functions πŸ’»
Python
105
star
12

tok

Fast and customizable tokenization 🚀
Python
65
star
13

aserve

Easily mock an API β˜•
Python
50
star
14

just

Just is a wrapper to automagically read/write a file based on extension
Python
48
star
15

xtoy

Automated Machine Learning: go from 'X' to 'y' without effort.
Python
47
star
16

spacy_api

Server/Client around Spacy to load spacy only once
Python
46
star
17

requests_viewer

View requests objects with style
Python
42
star
18

cant

For those who can't remember how to get a result
Python
33
star
19

aioyagmail

makes sending emails very easy by doing all the magic for you, asynchronously
Python
29
star
20

sysdm

Scripts as a service. Builds on systemd (for Linux)
Python
21
star
21

deep_eye2mouse

Move the mouse by your webcam + eyes
Python
20
star
22

reddit_ml_challenge

Reddit Machine Learning: Tagging Challenge
Python
19
star
23

inthenews.io

Get the latest and greatest in news (on Python)
CSS
19
star
24

crtime

Get creation time of files for any platform - no external dependencies ⏰
Python
16
star
25

natura

Find currencies / money talk in natural text
Python
15
star
26

rebrand

✨ Refactor your software using programming language independent, case-preserving string replacement πŸ’„
Python
15
star
27

emacs-kooten-theme

Dark color theme by kootenpv
Emacs Lisp
14
star
28

justdb

Just a thread/process-safe, file-based, fast, database.
Python
8
star
29

fastlang

Fast Detection of Language without Dependencies
Python
7
star
30

quickpip

A template for creating a quick, maintainable and high quality pypi project
Python
7
star
31

xdb

Ambition: Single API for any database in Python
Python
6
star
32

nostalgia_chrome

Self tracking your online life!
Python
5
star
33

cnn_basics

NLP using CNN on Cornell Movie Ratings
Python
4
star
34

kootenpv.github.io

Pascal van Kooten's website hosted on github.io
CSS
3
star
35

gittraffic

Save your gittrafic data so it won't get lost!
Python
3
star
36

flymake-solidity

flymake for solidity, using flymake-easy: live feedback on writing solidity contracts
Emacs Lisp
3
star
37

ppm

Safe password manager
C
2
star
38

automl_presentation

Example code for the presentation "Automated Machine Learning"
Python
2
star
39

dot_access

Makes nested python objects easy to go through
Python
1
star
40

feedview

View a feed url with `feedview <URL>`
Python
1
star
41

PassMan

android app for ppm
C
1
star
42

mockle

Automatic Mocking by Pickles
Python
1
star
43

emoji-picker

Python
1
star