Ask HN: I have ssh, they have ssh, how can we chat?

327 points by biturd ↗ HN
I don't want a dedicated client, I want to go back to the old ways of modem to modem over VT100 links and chatting that way. How can I ssh to another machine, or they to me, and we run a cli app that allows us to chat, something basic like `wall` I think would work, but I have never been able to get that to work.

I am on Mac OS X, and ideally I could do this without installing other software, using something built in.

122 comments

[ 3.9 ms ] story [ 277 ms ] thread
it could be done with a fifo, I believe the command "write" also does this.
+1 write Also you could install an irc server, bind it to localhost, and have a slightly better user experience.
An IRC server for this? Thermonuclear flyswatter.
True, but more scalable when you want a realtime text conversation with more than two people.
Already talking about scaling and we're not even sure it needs to scale...

;)

man talk
Not sure if it's installed by default on OSX, but you could use screen/byobu/tmux to share a terminal session and type to each other.
There should be a service which does throwaway accounts for ssh or ssh-via-web access with some extremely limited functionality, like talk, to keep the multiuser UNIX dream alive.

Maybe even spin up VMs on demand based on new hostname (if not seen before). First to claim = own. Some rate limiting function.

Shell accounts largely went away due to ease of use, but also local user exploits and abuse, but enh. If you virtualized the network (so you could reroute through a new IP on abuse, or let users own the IP) and restricted functionality it wouldn't be as bad.

No practical purpose, just fun.

As pwg@ mentioned, talk is worth looking at. Check the man pages for `mesg` and `talk` and `write`.
Have we forgotten about Zephyr?
> without installing other software
It's just kerberos/hesiod/afs/moira/etc. plus zephyr, third-party client, config files, etc. That doesn't even count as "installing other software", really. Oh, and cross-realm keys with any site you want, etc.

(I guess you could run Zephyr with somewhat less than that, and maybe it has improved in the past 15y for small deployments, but, when I tried in 2001 it was insane)

Just use tail -f and a bash function.

Put this in your .bashrc file:

    function talk { echo "$USER: $@" >> talkfile; }
then run:

    tail -f talkfile &
The & puts tail into the background so it continues running, and "talkfile" needs to be a file that both of you have write access to.

You can both communicate simply by using the talk function like any other bash command:

    talk whatever you want and it'll be written to talkfile
This works on Linux, not sure about Mac.

It's nice because it records what you say, so there's no need for the other person to be logged in to get your message, and you get a printout of the last few lines of conversation when you "login" (run the tail -f command). There's nothing extra to install either.

(edit, apparently say is already installed on OS X, so I renamed the function "talk")

You definitely don't want to name the alias 'say' because there's already an OS X command by that name. In fact, if you both have Macs and want to have some fun, create accounts for each other and use the 'say' command to use the speech synthesizer for chat. You can even choose different voices:

    man say
Nice suggestion!

Just to note, on the Mac there's already a /usr/bin/say, which invokes the text-to-speech. So if you don't create your function, SSHing to the friend's Mac and typing 'say whatever you want' will have an interesting but probably not desired effect :) I'll admit to having used this on a friend's machine once or twice for amusement.

(And invoking 'say' invokes the TTS even if you SSH in as a user other than the one logged in to the main GUI. I'm pretty sure this wasn't always the case; not sure when it changed.)

> (And invoking 'say' invokes the TTS even if you SSH in as a user other than the one logged in to the main GUI

Been this way since at least 2008 - I remember doing this back in school when bored in class.

BTW you can get say in linux too. Install the program festival and invoke it with:

    echo hello | festival -b --tts
There are existing (old) *nix commands for this. E.g., the `talk` command which I believe needs the talkd daemon running (ntalkd on OS X). There are also `wall` and `write`.

https://wiki.archlinux.org/index.php/Talkd_and_the_talk_comm...

Back in the day, we made much use of ytalk. One of talk, ntalk or ytalk should be available for any system you use.
ytalk is only an "apt-get install" away in Ubuntu. "write" is installed as standard, but ytalk is way better.
I love wall.

We have a 'jump' server, used to ssh into remote boxes, a truly public space with numerous users, such as myself, logged in poking around looking for the right hostnames etc. Having just learned of the wall command, I alt-tabbed to a session and thinking it fun to give a whirl. My message?

"Whats up playas"

A brief reprieve. But ah the word!

"Yo."

So came the flurry. A new message. And another. And another. Messages scratched across the server wall as though all the company had congregated outside this massive sleek black edifice where our words so glowed. I'm sure even some HR slavers or sales kin made the trek through the Terminal Wastes to bear witness to this spectacle. It was our digital Wailing wall except our shrieks were laughter. We were posting ASCII art by the time a sysadmin stepped in and put a stop to our revelry. Anymore posting would result in bans, temporary of course, but exile nonetheless.

Silence.

Then the CEO:

"Sup."

I'd just use libpurple, to match the prose!

(Sorry)

Indeed, just use "talk someuser".

Make sure to "mesg y" before :-)

Also, if you have a terminal multiplexer like tmux, you can have a very small horizontal split at the bottom to execute the `talk` command and use `less +F talkfile` in the top split to view the chat log with the ability to scroll back and search. You could also use tmux's built-in scrolling and just use `tail -f talkfile` but that would only show you the content which was tailed after you executed that command.
Actually I just realized you can use `tail -f -n +0 talkfile` to tail starting from the first line of `talkfile`. This works with both the BSD and GNU coreutils versions of `tail`.
Or, to get a continuous loop with timestamps:

    function talk { while read line ; do echo "$USER [`date +%T`]: $line" >> $talkfile ; done }
kids these days don't know how to talk(1), write(1) or finger(1)
even more gettho, just use tmux and both connect on it to write on the same file.
An easy way is to just create a new screen (see the Unix command "screen") and then open a text editor in it. The second participant then joins the screen (via screen -x) and now you both can type into the same editor.
I remember netcat being installed on OS X by default, you could ssh in and run it or pipe the port through ssh.
To be slightly more explicit for people who aren't used to using it this way, one person could run "netcat -l 12345" and the other could run "netcat localhost 12345". (Your netcat might also be installed as nc.)
I wrote this for use on a client project for a client I'm pretty sure won't consider this a breach of anything.

    #!/bin/bash
    # Simple chat system for when Skype is fucked.
    nick=${1?Usage: $0 nickname (e.g. $0 biturd)}
    chan=/tmp/yapchan
    echo "^D to exit chat." >&2
    tail -F "$chan" & tailpid=$!
    trap 'kill "$tailpid"' 0
    while IFS='' read -er line; do echo "<$nick> $line"; done >> "$chan"
If you're running this with multiple accounts, you may need to chmod a+w /tmp/yapchan, and if you're using MacOS on the server, you may need to use a different filename since MacOS has a per-user private /tmp.
If anybody is using this and encounters bugs, I’d be happy to hear them. I did my best to make it work reliably.
ssh to the same machine. $ mesg y $ talk <otherusername>
I'm not sure about OS X but most Linuxes have netcat installed.

There's also OpenSSL s_client/s_server for an encrypted connection, although you need to setup some certificates first.

Or if you're okay with less encryption-strength, `cryptcat`.
talk has been around for like...30 years now:

https://en.wikipedia.org/wiki/Talk_(software)

I used to love talk. No holding back with thoughts since they see you typing immediately. 8)
I really liked the talk idiom where you first typed something rude, then slowly erased it one letter at a time, and finally typed a euphemism. Like what people use strikethrough for now, but it was funnier in talk somehow.
Only idio^H^H^H^Hnice people use talk!
Talk is great because people can complete each other's sentences and such, which is impossible with instant messaging (unless people hit send for incomplete thoughts).
I actually really miss the user experience of 'talk' and 'ytalk'. Split-screen so people really could type at the same time, and touch-typists could type at the same time as reading what the other person was writing. Character-by-character, too, which helped improve the feeling of connection.
With ytalk you could escape to the shell and the other participants could see what you were doing. It was fantastic for showing classmates code I was working on.
WRITE(1) is pretty much ubiquitous. Even Mac OS X has it. Very old school.
yes, I have recently seen it being used in a movie. I think it was in Blackhat :D
I recall that on the Dynix (Sequent?) and SunOS lab workstations back in college (early 90s), users' TTYs had pretty open permissions. One could echo a message and redirect directly to your buddy's TTY. Also good for blasting annoying users from their session -- cat'ing binaries or chargen output was often enough.

There's something to be said of the old-school wonder of fingering random machines on the internet (say, from one's email bang path) for logged-in users then initiating talk sessions.

You can also create a screen session. The other user logs into your ssh server and uses screen -x to attach to your terminal.
talk user@host
User A logs into user B's machine. User A or B types

screen -S chat

The other user types

screen -xr chat

A lot of nice solutions have already been posted for talking. If you want to show some code, a shell session, your dwarf fortress, etc., you can look at screen/tmux with a shared guest account:

    # you type:
    $ screen -S session1 vim file.txt
    # and they can type (as the same user)
    $ screen -x session1

    # or with tmux, you type:
    $ tmux new -s session1 vim file.txt
    # they type (as the same user)
    $ tmux a -t session1
You can try it out with two terminals on your own.
This probably isn't want the OP wants, but this seems like a good spot to put in a plug for tmate[0]. There's not much to it but basically it provides a remote tmux server to share your current terminal. If you use their public server, you just run tmate and it spits out a randomly generated SSH connection string. The code is open source, so you can run your own server if you choose.

[0] http://tmate.io/

Very cool! I like the presentation on the landing page a lot. It's immediately apparent what it does.

The most difficult part of using this for me seems to be trusting tmate--not that tmate is inherently untrustworthy, but IMO untrustworthy by default is a good policy.

Well, the code is open source so you can go over it and compile from source if you want. The server is also open source, so you can run your own if you're concerned about the public server.
Nice! I'm sorry I missed that.
Yes! This is what I've been looking for, thank you!

Although, I agree with the "untrusted by default" sentiment of the fellow commenter below :/

EDIT: Oh, it comes with an open-source server? This is brilliant.

What's wrong with using 'wall'
When you say "they to me" it makes it sound like you want a peer-to-peer connection. Unless your internet service allows unsolicited incoming connections, then you will need to do NAT piercing. And if you are behind the same NAT (e.g., same ISP) then you will have to forward traffic through some third host who is not behind the NAT.

But when you mention "wall(1)" it makes it sound like you want to connect to some internet accessible UNIX host via ssh and chat to others who are also connected to that host.

Option 2 would be less complex.

Depending on what software is installed on the host you connect to, there are many possibilities. Back in the old days, talk(1) could be used for split screen chats. Today, tmux(1) would be my choice. Anything that uses UNIX domain sockets could work.

Proof of concept:

Does Darwin have logger(1), syslogd(8) and /etc/syslog.conf(5)?

Decide where to log the messages, e.g., /var/log/messages

Edit /etc/syslog.conf

Start syslogd

logger "your message"

less /var/log/messages

less -F /var/log/messages

tail -f /var/log/messages

Messages have date, time, priority (if any) and hostname.

You said "something basic"; this is about as basic as it gets.

While linux x86_64 only, this is precisely why I built sshtalk -- https://2ton.com.au/sshtalk, or just ssh 2ton.com.au to see for yourself, I leave it open as a public/free service
Thanks, this is great! Any hope that it will eventually support split-screen for personal chats, as ytalk does?
I opted out of split-screen in favour of inline with formatting and different colours... I always found it difficult to follow the split screen chats way back then ... that and it makes multi-person windows more difficult with smaller terminal sizes :-)
Makes sense!

My dad and I have been using it for our instant messaging. We were curious how possible it would be to have timestamps on messages. I suppose we could reprogram the ASM, but x86 ASM is a little inaccessible :)

I really didn't expect for it to carry any social features or aspects, in fact the reason I built it was so that it was a ephemeral as I knew how to make it. Timestamps contravene this goal a bit... but if you are genuinely interested re: same, the mods to sshtalk would be quite trivial to add. Despite it being assembler, it is very easy.
I had very low expectations of this until I ssh'd into 2ton.com.au. Wow, this is fantastic. It really brings my mind back into the BBS days.
Admittedly, I am no webguy, haha, my skills lie in old-school things... apologies if the web front doesn't do it justice
How does your SSHD setup work? Seeing that you allow passwordsless and keyless login.
Weird, I meant to do my last post in reply to this, sorry it isn't inline correctly.
Thanks - I now see that you implemented the ssh server functionality yourself. I am now busy reading the source code for HeavyThing including the code relating to SSH.
SSH2 specs are pretty clear about authentication methods. We (meaning me, the service provider) can accept or deny, negotiate any number of methods. With sshtalk, since all of the comms happen post-Perfect-Forward-Secrecy DH group exchange, I figure there is zero benefit for an anonymous chat service to remand any form of auth whatsoever, and sshtalk as I built it embodies that perfectly. It is not meant to authenticate YOU, it is meant to do the opposite of that, the only reason you know it is me you are talking to is because of domain inference and that I am @Sysop per the code itself. :-) all of these things I thought were good things.
Hey to "r3xin" and others like him who have tried to get "out" of my sshtalk, :q and exit, :eq, etc don't work. Ctrl-C will boot you straight out always, and any key during the intro "old-school demo TUI stuff I did" automatically cancels it. If you're going to type anything to me, kindly have the courtesy to say g'day :-)