Glitch Console Fun

Hey :wave:t2:

Glitch has always been great for the little web apps and static sites I’ve built in the past, but there’s a whole linux computer in there you can use to do so much more. Glitch’s web console lets you get at that computer in a web browser (which is great!), and I’ve always wanted that console access in a real terminal on my mac, but there’s no ssh (which is a bummer!).

Last night I spent a little time hacking together a way to make that work. First you need websocat and socat, but they aren’t included in the base glitch image. Fire up a new glitch-hello-node, and open the web terminal. Websocat is binary downloadable from github so wget it. Socat you have to build from source (wget it, follow the build instructions). Place the two executables in the /app folder.

Also in the /app folder, create a script named doit with the following contents,

./websocat -E -b ws-l:127.0.0.1:3000 sh-c:'./socat - exec:"bash -li",pty,stderr,setsid,sigint,sane'

and chmod+x it.

In package.json replace node server.js with ./doit

Now on your macbook you also need websocat and socat, which you can get from brew. Open up a terminal and run this command,

socat file:`tty`,raw,echo=0 SYSTEM:'websocat -b -E - wss\://your-glitch-name.glitch.me'

replacing your-glitch-name with your glitch name.

You should see the glitch console splash message and you’ll be logged in as the app user.

Happy glitching!

6 Likes

nice work putting that together!

it’s a little scary to use without any authentication though, isn’t it?

https://snail-cli.glitch.me/help/term.html

I’ve been publishing this command line tool for, among other things, connecting to the project terminal from inside a native terminal. this goes through Glitch’s API, the same as Glitch’s web console uses, so you’ll have to sign in to the tool with your Glitch account.

it has a lot of other issues though :person_shrugging:

2 Likes