
Ask HN: I have ssh, they have ssh, how can we chat? - biturd
I don&#x27;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.<p>I am on Mac OS X, and ideally I could do this without installing other software, using something built in.
======
JamesMcMinn
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")

~~~
tvon
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...](https://wiki.archlinux.org/index.php/Talkd_and_the_talk_command)

~~~
secabeen
Back in the day, we made much use of ytalk. One of talk, ntalk or ytalk should
be available for any system you use.

~~~
zik
ytalk is only an "apt-get install" away in Ubuntu. "write" is installed as
standard, but ytalk is way better.

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

~~~
kragen
If anybody is using this and encounters bugs, I’d be happy to hear them. I did
my best to make it work reliably.

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

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

~~~
drincruz
I used to love talk. No holding back with thoughts since they see you typing
immediately. 8)

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

~~~
mverwijs
Only idio^H^H^H^Hnice people use talk!

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

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

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

~~~
michaelmior
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/](http://tmate.io/)

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

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

~~~
wyc
Nice! I'm sorry I missed that.

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

------
2ton_jeff
While linux x86_64 only, this is precisely why I built sshtalk --
[https://2ton.com.au/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

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

~~~
2ton_jeff
Admittedly, I am no webguy, haha, my skills lie in old-school things...
apologies if the web front doesn't do it justice

~~~
sgt
How does your SSHD setup work? Seeing that you allow passwordsless _and_
keyless login.

~~~
2ton_jeff
Weird, I meant to do my last post in reply to this, sorry it isn't inline
correctly.

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

------
Animats
Mandatory XKCD: [https://xkcd.com/949](https://xkcd.com/949)

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

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

~~~
joelthelion
Still no improvements on this front.

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

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

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

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

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

~~~
c22
There's always [http://freeshell.org](http://freeshell.org).

~~~
weland
Which also has an amazingly friendly community.

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

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

------
peterwwillis
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](https://en.wikipedia.org/wiki/Talk_%28software%29)),
or the Write program
([https://en.wikipedia.org/wiki/Write_%28Unix%29](https://en.wikipedia.org/wiki/Write_%28Unix%29)),
or use Netcat
([http://hak5.org/episodes/haktip-82](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.

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

------
atxhx
I remember netcat being installed on OS X by default, you could ssh in and run
it or pipe the port through ssh.

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

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

------
atsaloli
man write

[http://ss64.com/bash/write.html](http://ss64.com/bash/write.html)

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)

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

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

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

------
danielhunt
[http://www.redbrick.dcu.ie/~c-hey/](http://www.redbrick.dcu.ie/~c-hey/)

    
    
        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.

------
philprx
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_...](https://github.com/paramiko/paramiko/blob/master/demos/demo_server.py)

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

------
brajesh
What's wrong with using 'wall'

------
andrewchambers
it could be done with a fifo, I believe the command "write" also does this.

~~~
opless
+1 write Also you could install an irc server, bind it to localhost, and have
a slightly better user experience.

~~~
chx
An IRC server for this? Thermonuclear flyswatter.

~~~
opless
True, but more scalable when you want a realtime text conversation with more
than two people.

~~~
JustSomeNobody
Already talking about scaling and we're not even sure it needs to scale...

;)

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

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

------
pwg
man talk

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

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

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

~~~
column
something like Firefox Hello?

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

[https://github.com/Spark-Innovations/SC4](https://github.com/Spark-
Innovations/SC4)

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

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

screen -S chat

The other user types

screen -xr chat

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

------
ninjakeyboard
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](http://www.computerhope.com/unix/write.htm)

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

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

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

~~~
wrayjustin
Or if you're okay with less encryption-strength, `cryptcat`.

------
c22
You could use this:
[https://github.com/kryptographik/ShuSSH](https://github.com/kryptographik/ShuSSH)

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

------
enterx
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!)

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

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

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

------
resca79
try `write`:

>usage: write user [tty]

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

------
strathmeyer
Have we forgotten about Zephyr?

~~~
joshu
> without installing other software

~~~
rdl
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)

~~~
joshu
No.

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

------
plg
unix command: kibitz

kibitz - allow two people to interact with one shell

[http://www.skrenta.com/rt/man/kibitz.1.html](http://www.skrenta.com/rt/man/kibitz.1.html)

------
yueq
talk user@host

------
kpcyrd

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

------
mayli
You can use write or screen/tmux.

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

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

------
Shalle
open up a screen session and type whatever you want.

------
db48x
install talk on one of your machines.

~~~
ctpide
talk is already build-in under Mac OS X

------
roka88
uyu

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

You can use "[https://telegram.org"](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.

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

