GithubHelp home page GithubHelp logo

elisescu / tty-share Goto Github PK

View Code? Open in Web Editor NEW
778.0 20.0 80.0 14.96 MB

Share your linux or osx terminal over the Internet.

Home Page: https://tty-share.com/

License: MIT License

Go 69.93% Shell 1.19% Dockerfile 0.92% Makefile 1.04% CSS 6.29% HTML 2.04% JavaScript 9.35% TypeScript 9.24%
terminal-share terminal-sharing go tty linux-terminal unix-terminal osx-terminal terminal-session

tty-share's Introduction

tty-share

tty-share is a very simple tool used to share your Linux/OSX terminal over the Internet. It is written in GO, results in a static cross-platform binary with no dependencies, and therefore will also work on your Raspberry Pi.

The remote participant needs not setup, and they can join the session from the browser or from the terminal (tty-share <secret URL>). The session can be shared either over the Internet, or only in the local network. When sharing it over the Internet (outside your NAT), tty-share will connect to proxy server that will mediate the communication between the participants. An instance of this server runs at tty-share.com, but you can run your own.

Demos

Local network session demo

Public session demo

Join a session from another terminal demo

Installing and running

Docker

If you only want to try it out, there's a Docker image you can use:

docker run -it elisescu/tty-share --public

Brew

If you are on OSX and use brew, then you can simply do a brew install tty-share.

Binary releases

Otherwise, download the latest tty-share binary release, and run it:

Running it

~ $ tty-share --public
public session: https://on.tty-share.com/s/L8d2ECvHLhU8CXEBaEF5WKV8O3jsZkS5sXwG1__--2_jnFSlGonzXBe0qxd7tZeRvQM/
local session: http://localhost:8000/s/local/
Press Enter to continue!

~ $

Sessions can be created as read only, with the --readonly flag. See --help for more.

Join a session

You can join a session by opening the session URLs in the browser, or with another tty-share command:

~ $ tty-share https://on.tty-share.com/s/L8d2ECvHLhU8CXEBaEF5WKV8O3jsZkS5sXwG1__--2_jnFSlGonzXBe0qxd7tZeRvQM/

Join a session with TCP port forwarding

You can use the -L option to create a TCP tunnel, similarly to how you would do it with ssh:

tty-share -L 1234:example.com:4567 https://on.tty-share.com/s/L8d2ECvHLhU8CXEBaEF5WKV8O3jsZkS5sXwG1__--2_jnFSlGonzXBe0qxd7tZeRvQM/

This will make tty-share listen locally on port 1234 and forward all connections to example.com:4567 from the remote side. The server needs to allow this, by using the -A flag.

Building

Simply run

go get github.com/elisescu/tty-share

The frontend code (the code that runs in the browser session) lives under server/frontend, and it is compiled into server/assets_bundle.go go file, committed to this git repo. To rebuild this bundle of web resources, make sure you have node and npm installed, and then run: make -C server frontend. Unless you change the browser/frontend code, you don't need to do this - the code is already precompiled and bundled in assets_bundle.go.

For cross-compilation you can use the GO building environment variables. For example, to build the tty-share for raspberrypi, you can do GOOS=linux GOARCH=arm GOARM=6 go build (check your raspberrypi arch with uname -a).

Security

tty-share connects over a TLS connection to the server, which uses a proxy for the SSL termination, and the browser terminal is served over HTTPS. The communication on both sides is encrypted and secured, in the same way as other similar tools are doing it (e.g. tmate, VSC, etc).

However, end-to-end encryption is on the TODO list. Otherwise, if you don't trust my tty-proxy installation, you can run your own.

Similar solutions

VSC (Visual Studio Code) Live Share

I've tried Visual Studio Code sharing, and it seems to work relatively well. One big advantage is that both persons in the session can write code, and navigate independently of each other. It also supports terminal sharing.

However, the two disadvantages with this tool are the need of logging in with a Github (or Microsoft) account, and having to install Visual Studio Code on the remote side too. I don't want to force the remote person to install VSC just for them to get access to a terminal session. Visual Studio Code might be popular in the web development circles, but it is not popular in the other development corners.

This is a great tool, and I used it quite a few times before. At the time I started my project, tmate.io didn't have the option to join the session from the browser, and one had to use ssh. In most cases, ssh is not a problem at all - in fact it's even preferred, but there are cases when you just don't have easy access to an ssh client, e.g.: joining from a Windows machine, or from your smartphone. In the meantime, the project added some support for joining a terminal session in the browser too.

Perhaps one downside with tmate is that it comes with quite a few dependencies which can make your life complicated if you want to compile it for ARM, for example. Running it on a raspberry pi might not be as simple as you want it, unless you use Debian.

Credits

tty-share's People

Contributors

antifob avatar dependabot[bot] avatar elisescu avatar fvcr avatar phearzero avatar strazto 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tty-share's Issues

Suppress "New connection from..."

This messes up my terminal, and I'd rather not see it - it is used for displaying a monitoring page only.
No need to know how many/when someone connects (preferably read-only)

Release on Docker Hub

It would be great if the container image was published as part of the release process.

Cannot type "option" characters on macbook

Cannot input any character using Option Key (⌥) public xterm terminal.

  • tty-share (2.4.0) started with -public option
  • It might be related to the Keyboard selection (TR-Q), but after switching to US keyboard the issue still persists
  • Tried different servers for running tty-share, local docker demo, several remote linux machines
  • Neither safari nor chrome works
  • xtermjs demo works fine typing those characters: docker run --rm -it -p3000:3000 xtermjs/xterm.js

Make local `-listen` binding opt-in, or allow `-listen` to use first available port in a range.

tl;dr

It's annoying that running a new session of tty-share fails if localhost:8000 is unavable, eg another tty-share session is using it. (especially when you only care about the public session)

It would be nice if the default was to bind to the first available port in a range, eg localhost:8000-8010. If 8000 is taken, then the session binds to localhost:8001 etc.

Details

It's great that tty-share's flexibility has been enhanced, but I find that a few new features detract from its vision as the "easy" non-astonishing method of sharing your terminal.

One such feature is the local session feature. I find that this feature typically makes launching parallel sessions annoying, or launching sessions when localhost:8000 has been bound, for example, if I'm running a local dev server.

The solution is fairly simple, of course, just give it the listen arg- tty-share -listen localhost:8001, but this step is still a step away from tty-share being the "easy mode" of session sharing.

This could be resolved by either:

  • Making the local address binding optional, or
  • Allowing users to specify a range of ports, similar to the mosh over which to iterate, & bind on, failing only if no port was available, ie tty-share -listen localhost:8000-8010.
  • A reasonable default would probably be localhost:8000-8010.
  • I'm not sure about
    • the best/most conventional syntax to specify port ranges in the argument, (localhost:8000-8010 vs localhost:8000:8010)
      • (mosh uses 8000:8010 syntax, but you also choose the bound address separately from the port, so it looks less weird because the colon only means one thing)
      • csf also uses the start:end convention, same note as above.
    • or whether its worth allowing multiple ranges, as in "localhost:8000-8010,8080,8888".

To me, specifying a port range feels like the better option

  • simpler from the perspective of users who just want the public proxy, and no worse for users who want to bind to a local port for whatever reason.
  • Besides the step of parsing the argument, iterating over the range & binding to a port, less complex application logic, as a local listening address is always used.

A few caveats:

  • One useful thing about this binding issue is that it does remind me that I've got a session running I might want to kill.
  • I was developing tty-share when I ran into this, so I was probably spinning up more sessions than the average user.

Possibly broken usages of Sprintf

Overview

The following warnings show up in my editor's linter:

$ go test
# github.com/elisescu/tty-share
./client.go:197:14: github.com/sirupsen/logrus.Warnf call has arguments but no formatting directives
./client.go:203:14: github.com/sirupsen/logrus.Warnf call has arguments but no formatting directives
./main.go:159:14: fmt.Sprintf call has arguments but no formatting directives

Patch

Is the intention something like this:

diff --git a/client.go b/client.go
index 61f278d..a78546f 100644
--- a/client.go
+++ b/client.go
@@ -194,13 +194,13 @@ func (c *ttyShareClient) Run() (err error) {
 			localTunconn, err := localListener.Accept()
 
 			if err != nil {
-				log.Warnf("Cannot accept local tunnel connections: ", err.Error())
+				log.Warnf("Cannot accept local tunnel connections: %s", err.Error())
 				return
 			}
 
 			muxClient, err := c.tunnelMuxSession.Open()
 			if err != nil {
-				log.Warnf("Cannot create a muxer to the remote, over ws: ", err.Error())
+				log.Warnf("Cannot create a muxer to the remote, over ws: %s", err.Error())
 				return
 			}
 
diff --git a/main.go b/main.go
index c8715a4..c092c46 100644
--- a/main.go
+++ b/main.go
@@ -156,7 +156,7 @@ Flags:
 	envVars := os.Environ()
 	envVars = append(envVars,
 		fmt.Sprintf("TTY_SHARE_LOCAL_URL=http://%s", *listenAddress),
-		fmt.Sprintf("TTY_SHARE=1", os.Getpid()),
+		fmt.Sprintf("TTY_SHARE=1"),
 	)
 
 	if publicURL != "" {

Public tty-share session is showing 404?

Hi,

I installed tty-share via Homebrew. Running tty-share --public shows a url:

$ tty-share --public
public session: https://on.tty-share.com/s/<...id...>/
local session: http://localhost:8000/s/local/
Press Enter to continue!

but then going to that URL shows a 404 page. Am I doing anything wrong? Thanks!

If it helps, pressing Enter shows this:

ERRO[0001] Server finished: listen tcp 127.0.0.1:8000: bind: address already in use 
tty-share finished

Connection refused to localhost on any port.

> tty-share  --readonly --command tmux --args "attach -t default --ignore-size" --public
public session: https://on.tty-share.com/s/<snip />/
local session: http://localhost:8000/s/local/
Press Enter to continue!
ERRO[0005] Cannot proxy the connection to the target HTTP server: dial tcp [::1]:8000: connect: connection refused

I've tried multiple ports...do I need to run tty-server manually? Both local and remote don't work.

I'm confused what I'm supposed to do.

Support for SSH keys

Most cloud providers and security concern users prefer SSH public keys; it would be great to see its implementation.

Let me know if there are any plans for its introduction in your roadmap.

Enable cross origin for wss server

Add option for websocket origin, similar to gotty's --ws-origin

--ws-origin value             A regular expression that matches origin URLs to be accepted by WebSocket. No cross origin requests are acceptable by default [$GOTTY_WS_ORIGIN]

Using gotty for now but would love to switch to tty-share.

Connecting over a local network

I discovered tty-share a couple of weeks ago and I have used its --public parameter to share it over the internet to a couple of friends so as to show them some python stuff.

However, I can not find a way to make it work over my local network. For instance, I run it on my rpi3b+ (debian 11 aarch64, tty-share 2.2.0, 192.168.1.130 local ip) and I get this output. Please notice that there is no extra output despite the --verbose parameter

$ tty-share -verbose
local session: http://localhost:8000/s/local/
Press Enter to continue!

Then I go to my desktop, open a browser, visit http://192.168.1.130:8000/s/local/ and I get a connection refused error! It even fails when I try connecting to it via the tty-share itself, as seen in the last gif of the readme!

$ tty-share http://192.168.1.130:8000/s/local/
Cannot connect to the remote session. Make sure the URL points to a valid tty-share session.

tty-share disconnected

The same thing applies if I run it on the desktop (debian unstable x64, tty-share 2.3.0). I run tty-share but I can not connect to it through the browser with http://192.168.1.2:8000/s/local/ but only with http://localhost:8000/s/local/, which is practically useless.
Is there something I am doing wrong? There is no such thing as a firewall anywhere.

Moreover, I would like to share my terminal without the need of tty-share.com. I have my own domain name, I have forwarded the port on my router properly, but a connection to http://mydomain.com:8000/s/local/ does not seem to work. Testing another app on the same port shows that the port is open and the app is visible on the internet as it should.

How do I build the server

What version of Go is preferred here as well as I am receiving the following error when i build the server:

make all
go-bindata --prefix frontend/public/ -o tty-server/assets_bundle.go frontend/public/invalid-session.html frontend/public/bootstrap.min.css frontend/public/index.html frontend/public/404.css frontend/public/tty-receiver.in.html frontend/public/404.html frontend/public/tty-receiver.js
make: go-bindata: Command not found
Makefile:24: recipe for target 'tty-server/assets_bundle.go' failed
make: *** [tty-server/assets_bundle.go] Error 127
tree tty-server
tty-server
├── server.go
├── server_main.go
├── session.go
└── websockets_connection.go

0 directories, 4 files

This is cloned from master on 4e898b24e456d80e70b4c0719b83717bcc123f87

Add reconnect logic to proxy client

From reading the client code there is no support for reconnect if the others side network was dropped.
This seems not optimal if the network gets disconnected when using the proxy

Does not build on riscv64

Hi, just wanted to let you know that tty-share does not build on riscv64 because you are using your own fork of creack/pty which does not support riscv64 yet. Have you considered switching to the upstream version?

go: downloading github.com/elisescu/pty v1.0.2
go: downloading github.com/moby/term v0.0.0-20200915141129-7f0af18e79f2
go: downloading golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876
go: downloading github.com/gorilla/websocket v1.4.2
go: downloading github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce
go: downloading github.com/gorilla/mux v1.8.0
go: downloading golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a
# github.com/elisescu/pty
../../../../../go/pkg/mod/github.com/elisescu/[email protected]/pty_linux.go:34:8: undefined: _C_uint
../../../../../go/pkg/mod/github.com/elisescu/[email protected]/pty_linux.go:43:8: undefined: _C_int

Certificate expired

Hello all!

From today https certificate is expired and i'm not able to use go.tty-share server.
Can you please renew it?

image

How to use it in the LAN?

Make runs can run normally.However, I want to use it in the LAN. I tried the following command, but none of them succeeded.
server(192.168.1.70):

  1. ./out/tty-server --url http://192.168.1.70:8090 --web_address 192.168.1.70:8090 --sender_address :7654 -frontend_path ./frontend/public
  2. sudo ./out/tty-server --url http://192.168.1.70 --sender_address :7654 -frontend_path ./frontend/public

As you can see, I tried it twice on the server.

client(192.168.1.70):

  1. ./out/tty-share --useTLS=false --server localhost:7654

web(192.168.3.44)
http://192.168.1.70:8090/s/qjeU3w5wrfckB-4yNQLsn6GbgpU_5fT8XQ0azTTpD1Y=

I received lERR_ADDRESS_UNREACHABLE

How can I work?

Issues building

I am trying to build tty-share on a raspberry pi. Probably this is more an issue of me not understanding golang well enough, but still I am trying to get some help here:

I installed the go following the steps here

        GOVERSION=go1.16.5.linux-armv6l.tar.gz
        mkdir ~/src && cd ~/src
        wget https://golang.org/dl/$GOVERSION
        sudo tar -C /usr/local -xzf $GOVERSION

        # append to .profile
        echo "PATH=\$PATH:/usr/local/go/bin" >> ~/.profile
        echo "GOPATH=\$HOME/go" >> ~/.profile
        # Update your shell with your changes:
        source ~/.profile
        # check version 
        go version

Then I run

go get github.com/elisescu/tty-share

followed by

cd ~/go/pkg/mod/github.com/elisescu/[email protected]
go build

However, this gives me the following error

go build github.com/elisescu/tty-share: copying /tmp/go-build3947162155/b001/exe/a.out: open tty-share: permission denied

What are the steps that I am missing?

Thanks!

go-bindata

On Ubuntu 18.04 go-bindata is not installed.
sudo apt-get install go-bindata

fixes it, but I think it would be better/easier if the build-script pulled it with the other dependencies?

doesn't work on raspberry pi?

pi@tiny:~/out $ ./tty-share.lin 
-bash: ./tty-share.lin: cannot execute binary file: Exec format error

I didn't try compiling, but it does work great on my other systems. Fun stuff, thank a lot. Just pointing out it doesn't seem to work out of the box for ARM.

Trying to open a session on ec2 ubuntu server

Getting this error

Cannot proxy the connection to the target HTTP server: dial tcp 127.0.0.1:8000: connect: connection refused tty-share.

What would be causing this? I tried two different internet connections with no luck.

OSS-fuzz

Can i submit this project to OSS-fuzz with a view of getting the binaries fuzzed? I would put you down as the engineering contact

Scroll the termanil in the browser

Scrolling in the browser with the mouse brings up commands in the shell history.
When for example you execute the ls -al command, it is impossible to scroll up.
In the same gotty it is possible to scroll, which is very convenient with commands such as ls.

Also weird scaling of text in the browser. If you expand the terminal or switch to full-screen, the text becomes smaller than if you open the default terminal in size and run tty-share.

gzip compressed data converted to hex format present in server/assets_bundle.go

Hello @elisescu,

I saw that on server/assets_bundle.go we have some compressed gzip files converted to hex format,
would it be possible to perform this conversion at build time instead of providing them in hex format?

I have been doing a comparison,
I convert the file in hex to gz and then open and compare to see if there is a difference between the files or not.

Would it make sense for you to generate these gz files at build time?

Thanks a lot!

Build and run on Windows?

Is there any reason this wouldn't work on windows?

I'm curious if anyone has tried it or documented it if it works and what the requirements are.

Make a link shorter

Sometimes copy-paste will not work, so re-enter full link is terrible. Maybe make a link shorter?

Support nerd fonts

It would be nice, if nerd fonts could be supported. These are quite common, if people play with their setup.

image

I haven't looked into it, but maybe it's enough to include one of the fonts and configure xterm to use it.

Build: need symlink

git clone https://github.com/elisescu/tty-share.git
cd tty-share
cd frontend
nvm use
npm install
npm run build # builds the frontend
cd -
make all

"make all" will fail. You need to symlink in the tty-share dir in the elisescu subdir:
user@hostname:~$ ls -alrt go/src/github.com/elisescu/
lrwxrwxrwx 1 username domain users 22 Nov 19 16:14 tty-share -> /home/username/tty-share

RGB 24bit Truecolor

Anything outside the basic 16 color palette looks awful. I know xterm.js added support for 24bit RGB color at some point. Is enabling that as simple as setting an option somewhere?

Neovim's support for truecolor has changed my world, but viewing it on a web browser via tty-share will make your eyes bleed.

server protocol

Hi,

As someone who doesn't really know go, it would be nice to know how to make custom server proxies.

Feature request: Set env vars

Hey, great piece of software - I'll 100% use this for my next online meeting.

I couldn't find an easy way to set env vars in the command executed by tty-share though.
Here's what I would like to be able to do:

  • have a static var set for all commands run by tty-share, similar what tmux is doing: TTY_SHARE=1. This way you could for example change your prompt when running inside tty-share.
  • another var to re-retrieve the public/local urls inside of the spawned command (TTY_SHARE_PUBLIC_URL=https://xxx TTY_SHARE_LOCAL_URL=http://localhost:8000/xxx)

You can right now already get around the first "issue" by using a custom shell function (see below), but I couldn't find a way to get the urls after the initial launch.

tty-share () {
  TTY_SHARE=1 command tty-share "$@"
}

Thanks for this epic alternative to tmate!

EDIT: Having an env var such as TTY_SHARE would also make it pretty easy to avoid running nested tty-share sessions (same as tmux)

Russian locale isn't working properly, invisible characters

Issue:
Writing russian locale (ru_RU.UTF-8) through browser terminal makes characters weird question marks at sharing computer end and invisible characters in browser client end.
Also, there's issue with erasing bash prompt in remote tty (at sharing computer end), because i write invisible characters (most likely tty-share doesn't expect these characters to be not shown, so it counts them too)

System:
Arch Linux with linux-lts 5.4.72-1 kernel
Using xfce4-terminal 0.8.9.2-2 with tty-share 0.6.1 from AUR

Issue shown in gif bellow
Peek 2020-10-30 10-23

Potential Augmentation

Hi there!

I am curious how difficult it would be to change the pty client from a websocket frontend to a go binary client? Instead of connecting to the session with a browser it would be nice functonality to tty_receiver -server tty-share.elisescu.com:7654 and have an interactive terminal.

Compile error

Running make out/tty-share results in:

tty-share/pty_master.go:10:2: cannot find package "github.com/elisescu/pty" in any of:
        /usr/lib/go/src/github.com/elisescu/pty (from $GOROOT)
tty-share/main.go:14:2: cannot find package "github.com/elisescu/tty-share/common" in any of:
        /usr/lib/go/src/github.com/elisescu/tty-share/common (from $GOROOT)

I could probably fiddle with it to make it run but it looks like there's a step missing in the makefile.

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.