Hacker News new | comments | show | ask | jobs | submit login
Ask HN: I have ssh, they have ssh, how can we chat?
327 points by biturd 684 days ago | hide | past | web | 121 comments | favorite
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.

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")

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`.


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!


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.


Then the CEO:


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


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.

Indeed, just use "talk someuser".

Make sure to "mesg y" before :-)

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

Ubuntu and Fedora come with espeak. Stumbled upon that fact when doing https://github.com/andreis/different

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

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`.

Combine this with multitail (http://www.vanheusden.com/multitail/) and you can even have multiparty conversation !

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.

I wrote this for use on a client project for a client I'm pretty sure won't consider this a breach of anything.

    # Simple chat system for when Skype is fucked.
    nick=${1?Usage: $0 nickname (e.g. $0 biturd)}
    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.

talk has been around for like...30 years now:


And YTalk for multi-way chat: http://linux.die.net/man/1/ytalk

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.

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.

I seem to recall this being on HN a few months ago: https://github.com/shazow/ssh-chat

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

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

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.

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.

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 :-)

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.

Mandatory XKCD: https://xkcd.com/949

Yeah, I remember that xkcd. It would be nice if there was the publishing date so that we can have a better context...

It has the dates in the archive[1], by hovering the links. That particular comic was published in 2011/09/09.

Still no improvements on this front.

If it's for file transfer (not long-term storage), MEGA is pretty nice. No registration required, clean and ad-free UI, supports huge files, etc.

Peer-to-peer file transfer or torrent over webRTC (webTorrent) maybe? https://instant.io/

"Oh, your DropBox is full? Ok..."

WRITE(1) is pretty much ubiquitous. Even Mac OS X has it. Very old school.

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.

yes, I have recently seen it being used in a movie. I think it was in Blackhat :D

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.

There's always http://freeshell.org.

Which also has an amazingly friendly community.

We do this all the time, at-least for past 5 years or so while implementing our opensource project.

We login to same server to do :

#create a screen

screen -S chat

#Both of us will join the screen:

screen -x chat

#Now we can see each other typing. Make typing easier do:

write pts/<id> username

#Make sure there is another login and use that pts <id> above.

After we typed our lines, to indicate I'm waiting for his response. I'll adding 2 or 3 newlines.

That's it ! :)Simple chat over ssh.

As pwg@ mentioned, talk is worth looking at. Check the man pages for `mesg` and `talk` and `write`.

You can't connect ssh clients like you would modems. If the machines are on a public network you ssh to another person's sshd, then use terminal chat programs. If you're both behind a NAT, one of you needs to port-forward to your host's sshd, or use STUN, TURN or ICE servers, or maybe just IPv6.

Once connected to someone's host, use the Talk program (https://en.wikipedia.org/wiki/Talk_%28software%29), or the Write program (https://en.wikipedia.org/wiki/Write_%28Unix%29), or use Netcat (http://hak5.org/episodes/haktip-82) to open a two-way dialogue between terminals. Netcat is the simplest of them all because it just opens a two-way tcp session, and technically only one of you needs netcat while the other just needs a telnet client or equivalent.

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.

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.)

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.

man write


You would need to run two instances of write : you would write to your friend and your friend would write to you.

Just press Enter twice when you are done with your turn (I.e. "over" as in, transmission over)

write anybody?? I must be too old for this shit then.

just write <systemusername> <tty|ptsname> enter message and quit with ctrl-d

from man page:

     The write utility allows you to communicate with other users, by copying lines from your terminal to theirs.

     When you run the write command, the user you are writing to gets a message of the form:

           Message from yourname@yourhost on yourtty at hh:mm ...

     Any further lines you enter will be copied to the specified user's terminal.  If the other user wants to reply, they must run write as well.

     When you are done, type an end-of-file or interrupt character.  The other user will see the message ‘EOF’ indicating that the conversation is over.

     You can prevent people (other than the super-user) from writing to you with the mesg(1) command.

     If the user you want to write to is logged in on more than one terminal, you can specify which terminal to write to by specifying the terminal name as the second operand to the write command.  Alter‐
     natively, you can let write select one of the terminals - it will pick the one with the shortest idle time.  This is so that if the user is logged in at work and also dialed up from home, the message
     will go to the right place.

     The traditional protocol for writing to someone is that the string ‘-o’, either at the end of a line or on a line by itself, means that it is the other person's turn to talk.  The string ‘oo’ means
     that the person believes the conversation to be over.

That was always a fun time. At my college, ttys were globally writable by default for some reason. Once when a professor was demoing something in front of class on his terminal, a few of the haxx0rs slipped out to the computer lab to bomb his tty with ascii art. Good times.


    1. Install that on a machine.
    2. Both SSH to the that machine machine.
    3. Type: `hey <username>`, press enter.
    4. Enter your (optionally multiline) message to your friend.
    5. CTRL+D (on windows, at least) to send the message.
    6. ????
    7. Profit.

Use Paramiko (Python) to code a quick server based on : demo_server.py Share what is typed between clients using fifo, shared file (bad!) or SQLite. See: https://github.com/paramiko/paramiko/blob/master/demos/demo_...

You can also create a screen session. The other user logs into your ssh server and uses screen -x to attach to your terminal.

What's wrong with using 'wall'

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...


I highly recommend ytalk, available as a package in most repos, as the solution here. Not only does it support multi user chat across the network (you can send talk requests to user@host), it has a shell escape feature which means you can open a vim buffer inside your chat session for collaborative editing.

ssh to the same machine. $ mesg y $ talk <otherusername>

man talk

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.

It might not be exactly what you're looking for but you might take a look at https://github.com/DSUOSS/unix-chat.

I'm working on a secure chat client that runs in a browser (so nothing to install). If you're interested in being a beta tester send me your email address and I'll send you an invite.

something like Firefox Hello?

It's similar insofar as there's nothing to install. But it's text only at the moment. It's based on this:


I'm a huge fan of not using the system chat tools for this but to write your own chat client. But instead of a simple text file I'd use a small database like sqlite or a logger because I want to make sure that the chatters don't run into the trouble of fighting for the write access to that file. Also if you do this a few weeks the file might get that big, that you would like a database engine to parse it anyway.

PS: Huge kudos for the question, btw. This is the kind of stuff that really improves your ability to use your system well.

User A logs into user B's machine. User A or B types

screen -S chat

The other user types

screen -xr chat

Lots of custom solutions in this thread, but there's already inbuilt commands for talking installed by default on every Unix box.

Log into a box, use 'who' to see which terminal they're using, and use 'write' to send a message there.

Or be lazy and just use 'wall' (write all) like I do.

Despite the fact that you both have SSH, you can still pick up the phone and call them. :) +1 for write. http://www.computerhope.com/unix/write.htm

netcat to the rescue!

You run:

  nc -l 5000
They run:

  ssh [yourhost] nc localhost 5000
The only issue I see is that you apparently can't get netcat to only listen on localhost so others could join in in theory.

There are many netcats, some of them can bind to localhost. ncat (Nmap's nc) even has a --chat option for multi-party chats. It also has SSL options, so you could just throw the ssh away and use it exclusively.

> get netcat to only listen on localhost

nc -l 5000

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`.

Run an irc bouncer like ZNC, they usually have a partyline plugin/functionality that lets you chat as if you were on an irc server, but locally.

check the following *nix utilities:

ssh one box to another, then:

who -uT // show who is connected to a machine and will they recieve message sent with write or wall command

write // sends a message to another user (tty). dont do this as it can confuse the other user by inserting the message in the middle of his current output.

wall //send a msg to all of the logged in users

talk & talkd // client and server. (old school rulz!)

I'm surprised nobody has mentioned "wall". Not great for chatting but damnably useful for unmissable comms with others on a box.

The OP specifically said "something basic like `wall` I think would work, but I have never been able to get that to work", and there are multiple other comments mentioning wall.

You could ssh into another machine, run a screen session, launch a shell and start chatting inside the shell

try `write`:

>usage: write user [tty]

If you are using the same account: emacs --daemon (once), emacsclient -t (for everyone).

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)


Once you get ytalk running, the next step is to install colossal cave adventure.

unix command: kibitz

kibitz - allow two people to interact with one shell


talk user@host

    apt-get install nmap
    ncat --chat -lp 1234

You can use write or screen/tmux.

a shared screen session ? screen -x with any editor or just 'cat' running

tunnel netcat through SSH :D for fun, but probarbly not profit!

open up a screen session and type whatever you want.

install talk on one of your machines.

talk is already build-in under Mac OS X


This does not directly answer your question. But there is a way using third party software.

You can use "https://telegram.org" telegram messsenger.

It works flawlessly from the cli.

Yes, you cannot use it if you don't want your chats to pass through a third party server. But maybe you can try out the "secret chat" feature with auto destroy feature.

The traditional options have already been listed by others here. I just wanted to tell something which is easy to setup and also reliable.

Doesn't telegram require that you use a cell phone number to register? OP wants to have ssh as the only requirement.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact