This Node.js script provides secure, remote shell access to your machine via a web browser, utilizing SSH tunneling and the ttyd terminal emulator.
- Secure SSH Tunnel: Establishes a reverse SSH tunnel to
localhost.run, exposing a local port securely over the internet. - ttyd Integration: Downloads, installs (if necessary), and runs the
ttydterminal emulator, providing a browser-based terminal interface. - Password Protection: Implements basic password authentication for accessing the shell.
- Customizable Theme: Sets a custom theme for the
ttydinterface. - Colab Support : Optionally embeds the terminal within a Google Colab notebook using an iframe.
- Node.js: Ensure you have Node.js installed on your machine.
- SSH Client: You need an SSH client installed and configured (e.g., OpenSSH).
- localhost.run Account: An account on https://localhost.run (free tier available) for SSH tunneling.
- Clone the Repository: Clone this repository to your machine.
- Install Dependencies: Navigate to the project directory and run
npm install. - Modify Script (Optional):
- Update the
sshcommand in theshell()function if you're using a different tunneling service or port. - Adjust the
ttydoptions (e.g., theme, font) as needed.
- Update the
- Run the Script: Execute the script using
node your-script-name.js.
- SSH Tunnel: The script establishes a reverse SSH tunnel to your
localhost.runaccount, making a local port (default: 8568) accessible publicly. - ttyd Setup: It downloads and installs
ttydif not found, then starts attydserver instance on the specified port, serving thedoshscript. - Password Authentication: The
doshscript prompts for a password and grants shell access only if the entered password matches the randomly generated one. - Browser Access: You can then access the terminal in your web browser using the provided
localhost.runURL and password.
To use this script within a Google Colab notebook:
- Enable the
colabflag when calling theshell()function:shell(colab = true). - Ensure you have a library like
jsdominstalled in your Colab environment to provide DOM functionality for the iframe.
- Strong Password: Choose a strong and unique password for your
localhost.runaccount. - Limited Access: Be mindful of the commands you execute in the remote shell.
- Close Tunnel: Terminate the script or close the SSH tunnel when you're finished to prevent unauthorized access .
This script is provided for educational and informational purposes only. Use it at your own risk. The authors are not responsible for any misuse or damages caused by this script.