Skip to content

Instantly share code, notes, and snippets.

@pojntfx
Last active March 4, 2022 23:10
Show Gist options
  • Save pojntfx/d777dce3efeee3dd338020a023abdd43 to your computer and use it in GitHub Desktop.
Save pojntfx/d777dce3efeee3dd338020a023abdd43 to your computer and use it in GitHub Desktop.
Share a terminal from Debian to the web using ttyd and localhost.run

Shortened link to this Gist: https://git.io/JPMB8

To use, run:

curl -L 'https://git.io/JPMBa' | bash -s -- sharedusername sharedpassword

Or if you only have wget installed, run:

wget -qO- 'https://git.io/JPMBa' | bash -s -- sharedusername sharedpassword

Now, send the printed URL to the person you want to share your shell with, press ENTER and run:

tmux

You should now have a shared shell.

#!/bin/bash
export USERNAME="$1"
export PASSWORD="$2"
sudo apt update
sudo apt install -y curl tmux openssh-client
curl -L -o /tmp/ttyd https://github.com/tsl0922/ttyd/releases/download/1.6.3/ttyd.$(uname -m)
sudo install /tmp/ttyd /usr/local/bin
rm -f ~/.ssh/id_rsa.ttyd*
ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa.ttyd -q -N ""
ttyd -i lo -c "${USERNAME}:${PASSWORD}" tmux attach &
ssh -tt -i ~/.ssh/id_rsa.ttyd -R 80:localhost:7681 localhost.run &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment