npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

p2pshell

v0.0.10

Published

Spawn shells anywhere. Fully peer-to-peer, authenticated, and end to end encrypted

Downloads

2

Readme

p2pshell

Spawn shells anywhere. Fully peer-to-peer, authenticated, and end to end encrypted.

Install

npm i -g p2pshell

Usage

# Create keys
p2pshell-keygen [-f keyfile] [-c comment]

# Create a P2P server
p2pshell-server [-f keyfile] [--firewall filename] [--disable-firewall] [--protocol name]

# Connect to a P2P shell
p2pshell <server key or name> [-f keyfile]

# Local tunnel that forwards to remote host
p2pshell <server key or name> -L [address:]port:host:hostport

# Copy files (download and upload)
p2pshell-copy <[@host:]source> <[@host:]target> [-f keyfile]

Use --help with any command for more information, for example p2pshell-server --help.

First steps

Keys are automatically created with a default filename on first run.

Otherwise, you can first do:

p2pshell-keygen

Just connect to servers (they have to allow your public key):

p2pshell <server name or public key>

You could also create a server:

p2pshell-server

~/.p2pshell/authorized_peers file will be empty, denying all connections by default.
Public keys can be added to the list to allow them in real-time.

Or you can use the --disable-firewall flag to allow anyone to connect, useful for public services like game servers.

Known peers

There will be a file ~/.p2pshell/known_peers.

Add named peers to the file like for example:

# <name> <public key>
home cdb7b7774c3d90547ce2038b51367dc4c96c42abf7c2e794bb5eb036ec7793cd 

Now just p2pshell home (it saves you writing the entire public key).

p2pshell-copy

Similar to scp. It works with files, and with folders recursively.

For the next examples, remote_peer is a name that can be added to the known_peers file.

Upload a file from your desktop to a remote server:

p2pshell-copy ~/Desktop/file.txt @remote_peer:/root/file.txt

Download a file from a remote server to your desktop:

p2pshell-copy @remote_peer:/root/database.json ~/Desktop/db-backup.json

Note: in the future, the @ might be removed.

You can also use the public key of the server directly (without @):

p2pshell-copy ~/Desktop/some-folder cdb7b7774c3d90547ce2038b51367dc4c96c42abf7c2e794bb5eb036ec7793cd:/root/backup-folder

Local tunnel

Client

It creates a local server, and every connection is forwarded to the remote host.

In this example, creates a local tunnel at 127.0.0.1:2020 (where you can connect to),
that later gets forwarded to a remote server which it connects to 127.0.0.1:3000:

p2pshell remote_peer -L 127.0.0.1:2020:127.0.0.1:3000

Instead of remote_peer you can use the server public key as well.

You can also pass several -L to run multiple local servers that remote forwards:

p2pshell remote_peer -L 2020:127.0.0.1:3000 -L 2021:127.0.0.1:3000 -L 2022:127.0.0.1:3000

Server

By default, p2pshell-server runs a server with full access, including forwarding to all hosts and ports.

You can run a server with restricted permissions to allow forwarding a specific host and port only.

Let's say you have a local project like a React app at http://127.0.0.1:3000/,
you can create a restricted server to safely share this unique port like so:

p2pshell-server --protocol tunnel --tunnel-host 127.0.0.1 --tunnel-port 3000

Or if you want to allow multiple hosts, port range, etc:

p2pshell-server --protocol tunnel --tunnel-host 127.0.0.1 --tunnel-host 192.168.0.25 --tunnel-port 1080 --tunnel-port 3000 --tunnel-port 4100-4200

Clients trying to use any different hosts/ports are automatically disconnected.

Multiple keys

To have multiple servers, you need multiple keys.

Generate another key:

p2pshell-keygen -f ~/.p2pshell/my-server

Now create a new shell server:

p2pshell-server -f ~/.p2pshell/my-server --firewall ~/.p2pshell/my-server-firewall

The client also accepts -f in case you need it.

Restrict server protocols

This is the list of server protocols:

  • shell
  • upload
  • download
  • tunnel

By default, all of them are enabled when running a server.

For example, you could limit it to shell only:
p2pshell-server --protocol shell

Or only allow file upload and/or download:
p2pshell-server --protocol upload --protocol download

Restrict to tunnel only:
p2pshell-server --protocol tunnel

For example, if you only allow tunnel, then any attempt from clients to shell into the server will auto disconnect them.

License

MIT