Settings

Theme

Devzat – Chat over SSH, with some nice quality-of-life features

github.com

435 points by humanperhaps 2 years ago · 110 comments

Reader

hiAndrewQuinn 2 years ago

I have a Raspberry Pi running a read-only server where some friends and I have a "poor man's IRC" chat, in that we all log in from Termux and post messages to one another using `wall`. It's absolutely ridiculous and I love it.

  • thejosh 2 years ago

    It's one of those things that if you need to ask why, you'll never understand :-)

  • complaintdept 2 years ago

    Install `finger` and you've practically got a social media platform.

    • queuebert 2 years ago

      .plan was the original status update.

      • complaintdept 2 years ago

        Indeed, I wish there was something like it today with a modern design. Like a DHT with your public key fingerprint as a lookup. Anyone who 'follows' your .plan also hosts it as a torrent. You 'approve' followers by signing your .plan file with their pubkey, or for a fully public .plan, just sign with your private. Blah blah blah decentralized cypherpunk social media utopia.

        • anacrolix 2 years ago

          Oh man, I've been working on this stuff for years. End users just don't care. Devs just reinvent the wheel in dumbass languages. The tech for this stuff has existed for 15 years, there's nothing to invent. It's ready now.

          https://github.com/anacrolix/btlink https://github.com/anacrolix/dht

          • complaintdept 2 years ago

            Thanks, I'll check these out. I have some hope that something like this could take off because of the popularity of Mastodon. I think the problem is that there has to be a major impetus for lots of people to switch, and it has to be completely brain dead stupid simple to set up, and to have it work fairly transparently so they don't feel like they're doing something completely new and different. Unfortunately decentralized services tend to add overhead, and user's expectations have been primed with centralized tech. We might see people care about stuff like this if we get more online censorship with government taking a closer look at tech lately.

        • rakoo 2 years ago

          That's basically what ssb or dat are

    • kouru225 2 years ago

      I’m trying to google finger and all I get is fingerprint software

      • LawnGnome 2 years ago

        https://en.wikipedia.org/wiki/Finger_(protocol)

        An old, old Internet protocol that was used to get information on a user, and could be used by users to post updates from their .plan files. Essentially plaintext social media for people with Internet connections in the 80s and (early-ish) 90s.

        • hiAndrewQuinn 2 years ago

          Reimplementing it (well, the CLI program, `finger`) also happens to be the final exercise of Haskell Programming from First Principles, after 1200 pages of glorious buildup from the lambda calculus forward, in case that sells anyone on trying it ;)

        • whartung 2 years ago

          Famous for enabling one of the very early Internet Worms.

          https://en.m.wikipedia.org/wiki/Morris_worm

        • mercutio2 2 years ago

          I had that "oh crap, I'm old" moment when my initial reaction was "what? You've never heard of finger?!" and then I remembered I last used it in the late 90s.

          I'm glad your reaction was to assist the young folks. :)

  • _joel 2 years ago

    Yea, came here to say, what about wall! :)

rwmj 2 years ago

I wonder if you could do something similar with an ssh account which is hard-wired to run 'ytalk' (https://en.wikipedia.org/wiki/Talk_(software)).

  • codazoda 2 years ago

    Probably. See my comment (and example repo) elsewhere about running any old binary when someone connects.

    • Borg3 2 years ago

      Or you can just run IRC client on start. Just trap SIGINT and SIGTSTP, run simple or modified client that cannot do exec or escape to shell and you are done :)

    • jagged-chisel 2 years ago

      Spoiler: set the user’s shell to any old binary, like a chat app.

qudat 2 years ago

Pretty neat! We implemented something similar with an IRC chat app (senpai) in our SSH app (pico.sh). After the user creates an account, it lets users connect to our public IRC bouncer with a single command (`ssh pico.sh -t chat`).

ref: https://pico.sh/irc

codetrotter 2 years ago

See also: ssh-chat by shazow from ~10 years ago written in Go

  ssh chat.shazow.net
The most amazing part is perhaps the fact that this one is still around, 10 years later! Try it yourself and you’ll see :)

Discussion at the time:

https://news.ycombinator.com/item?id=8743374

Source code in GitHub repo here:

https://github.com/shazow/ssh-chat

  • quackduck 2 years ago

    ssh-chat sort of inspired devzat. here's the story: I used to live in dubai at the time and for some odd dns reasons I could never actually join ssh-chat, but it acted as proof that ssh chats are possible, and so I decided to make my own version of it. then I moved to the us and was actually able to use both ssh-chat and devzat.

    • nojs 2 years ago

      > odd dns reasons

      I would love to hear more about this

    • codetrotter 2 years ago

      That’s so cool and nice :D

      Any idea what we could do to allow all of the people still in Dubai to join chats over ssh too?

languagehacker 2 years ago

I'd be curious whether there's any security concerns on this one. Could an attacker craft a message that gets access to execute commands into a client terminal?

  • qudat 2 years ago

    This is not sshd, this is a golang binary that uses the stdlib ssh lib. You would have to either a) figure out how to escape out of a golang binary, or b) if the go code executes shell commands with some user provided text, trying to shell inject something in there.

    • cwillu 2 years ago

      Or convince the ssh daemon to pass on terminal escape codes to another user.

      https://nvd.nist.gov/vuln/detail/CVE-2021-33477

      • raggi 2 years ago

        yup, not an extensive list, but further demonstrative:

          - terminal emulators are not security hardened clients against malicious actors
          - ssh lacks PKI and is inconvenient so users never do prekeying in practice, so it's TOFU / zero server assertion in most practical cases (i.e. easy to mitm)
          - ssh channel features are a constant concern, for server resources and for client features like agents, agents are easy to disable
          - most ssh implementations don't scale that well, it wasn't ever really a goal to do so
          - there are few tools for auditing and monitoring, unlike the common protocols/services/clients
        
        fun for toys, but i wouldn't put credit card details in there, unlike some streamers started doing lately.
        • cwillu 2 years ago

          ssh definitely supports PKI, it's just not the standard workflow for individuals

               ssh-keygen (1):  
          
               ssh-keygen supports signing of keys to produce certificates that may be used for user or host authentication.
               Certificates consist of a public key, some identity information, zero or more principal (user or host) names and
               a set of options that are signed by a Certification Authority (CA) key.  Clients or servers may then trust only
               the CA key and verify its signature on a certificate rather than trusting many user/host keys.  Note that
               OpenSSH certificates are a different, and much simpler, format to the X.509 certificates used in ssl(8)
      • quackduck 2 years ago

        whoa

  • Tepix 2 years ago

    You may not want the chat server owner to know which public ssh key you are using for privacy reasons.

    Workaround: Specify another ssh keypair

  • freedomben 2 years ago

    Yeah, though SSH is already very mature at processing text, so it's a surprisingly good fit for a chat. I would also remember that any machine you SSH from is going to give the server some metadata like IP address, public keys (which aren't useful as creds but can be for tracking). Really fun little project though

    • tjoff 2 years ago

      SSH might be, but maybe not your terminal. Which the very least can possibly trick you using escape codes. Also, unless my memory fails me 'cat'ing an untrusted file isn't recommended for security reasons.

      Additionally you should disable SSH forwarding. Relevant thread from the startup selling coffee over SSH: https://news.ycombinator.com/item?id=40227624

  • phoyd 2 years ago

    I'm also interested. Setting up a passwordless SSH account for some public service sounds like a good way to give your machine away to North Korean hackers, because you forgot to set someting in /etc/sshd to "no".

    Is there a usable description somewhere on how to do this safely?

codazoda 2 years ago

I experimented with writing a shell replacement a while back. Turns out you can just run any old program. Here’s and example “hello world” shell replacement written in Go.

https://github.com/codazoda/goshell

  • jagged-chisel 2 years ago

    > Turns out you can just run any old program.

    It’s amazing how simple some things are. Similarly, an HTTP server can also run any old binary in response to an incoming request. As long as it produces output that looks like an HTTP response, the client will receive that response.

quackduck 2 years ago

so sorry for it being down right now. hn hug of death is real

  • humanperhapsOP 2 years ago

    Didn't think about that when posting - my bad

  • xyst 2 years ago

    Guess it’s only useful as a toy :)

    • bjoli 2 years ago

      Or the person never expected more than a couple of hundred concurrent users and dimensioned the container or whatever after that.

      I once wrote a similar chat, but much much worse in many ways, that could easily handle thousands of concurrent users, but hosted it on a 1mbit residential line. When Slashdot hit it I stood no chance.

    • quackduck 2 years ago

      I just have a really shit server

      • mro_name 2 years ago

        which is great for human scale! Don't serve billions and burn the planet doing so.

yu3zhou4 2 years ago

There was a beginner friendly machine to hack on HackTheBox where you had to hack a Devzat instance

freedomben 2 years ago

Cool, the source code is amazingly readable. Also love the sense of humor :-D such as https://github.com/quackduck/devzat/blob/main/commands.go#L1...

  • knodi 2 years ago

    When I read this comment, thought good readability it’s got to be Go

    • Aeolun 2 years ago

      The readability might be nice, but the way files are structured makes no sense to me.

      In PHP/Typescript there’s always a direct correspondence between imports and file locations, but Go baffles me.

    • cdelsolar 2 years ago

      why is this downvoted?

jasonjayr 2 years ago

As a gentle reminder, if you are forwarding your ssh-agent by default, you should connect with:

    ssh -o 'ForwardAgent no' $host
So your secure identities are not exposed to a random ssh server ...
  • Aeolun 2 years ago

    Forwarding your agent by default (to all hosts!) sounds like a terrible idea.

sdsd 2 years ago

I love stuff like this. I made a widget for MacOS where you can see incoming |hi messages sent to your Urbit, as a kind of poor man's p2p chat. But I didn't add a feature to send hi messages, so you still need a CLI for that.

You can see what it looks like here: https://www.youtube.com/watch?v=_bAx4Jx39jE&t=384s

(it's the widget in the bottom right of the screen)

lynx23 2 years ago

Related: Does anyone by chance know how to configure an "anonymous" ssh account that always runs the same program? This would be great for making text mode games available to everyone without needing to support different platforms, now that windows actually ships with ssh.

xyst 2 years ago

Is this working for anybody else?

I created a throwaway ed25519 key, reconfigured ssh config, and tried to connect with ‘ssh chat’

Nothing loads. ‘ssh -v chat’ isn’t helpful either. ping and nc (on both 22 and 443) show the server (or load balancer) is accessible for me.

Maybe a “hnfp DoS” (hacker news front page DoS)?

  • n2e 2 years ago

    Have you tried connecting with the actual hostname directly instead of an alias?

    Edit: nvm the author said it’s down

1vuio0pswjnm7 2 years ago

https://man.netbsd.org/authpf.8

https://man.openbsd.org/authpf

tcsenpai 2 years ago

If you want to use my server, it might be a little more powerful than the current one. I would self host but to be honest I'd prefer helping out with the main instance. In case, I am here

Tepix 2 years ago

Looks like ascii colors aren't being filtered correctly.. which is a pretty big issue. White on white isn't very readable... :-)

localfirst 2 years ago

what sort of server resource usage is this like right now as you are getting a ton of traffic?

also noticed that people were able to run commands but permission denied. that kinda freaked me out. eventually somebody is going to figure out how to escape the go binary

nedpat 2 years ago

This is actually cool!

But unless I'm missing something, what's the difference between this and IRC?

ipsum2 2 years ago

Doesn't seem to be working, the chat is frozen and I can't type anything.

aa-jv 2 years ago

This is great, now we just need a way to host it on our mobile phones.

danslo 2 years ago

I appear to have crashed the server with "tic 999", sorry guys!

tempestlxc 2 years ago

Chatting via SSH has given me a lot of insights. Thank you.

ingen0s 2 years ago

This makes my list for top of the year, nice work.

callwhendone 2 years ago

ssh: connect to host devzat.hackclub.com port 22: Connection refused

PORT STATE SERVICE

22/tcp closed ssh

Nmap done: 1 IP address (1 host up) scanned in 1.18 seconds

----

overloaded?

styczen 2 years ago

Normal talk in unices system can do that.

Irc have exange data between server and minimalize data trafic.

still irc is better, but meybe in future

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection