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.
node server.js with
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.