TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

327 pointsby biturdalmost 10 years ago
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.

54 comments

JamesMcMinnalmost 10 years ago
Just use tail -f and a bash function.<p>Put this in your .bashrc file:<p><pre><code> function talk { echo &quot;$USER: $@&quot; &gt;&gt; talkfile; } </code></pre> then run:<p><pre><code> tail -f talkfile &amp; </code></pre> The &amp; puts tail into the background so it continues running, and &quot;talkfile&quot; needs to be a file that both of you have write access to.<p>You can both communicate simply by using the talk function like any other bash command:<p><pre><code> talk whatever you want and it&#x27;ll be written to talkfile </code></pre> This works on Linux, not sure about Mac.<p>It&#x27;s nice because it records what you say, so there&#x27;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 &quot;login&quot; (run the tail -f command). There&#x27;s nothing extra to install either.<p>(edit, apparently say is already installed on OS X, so I renamed the function &quot;talk&quot;)
评论 #9716903 未加载
评论 #9716812 未加载
评论 #9716811 未加载
评论 #9716978 未加载
评论 #9716866 未加载
评论 #9718381 未加载
评论 #9720296 未加载
评论 #9727550 未加载
评论 #9718142 未加载
kragenalmost 10 years ago
I wrote this for use on a client project for a client I&#x27;m pretty sure won&#x27;t consider this a breach of anything.<p><pre><code> #!&#x2F;bin&#x2F;bash # Simple chat system for when Skype is fucked. nick=${1?Usage: $0 nickname (e.g. $0 biturd)} chan=&#x2F;tmp&#x2F;yapchan echo &quot;^D to exit chat.&quot; &gt;&amp;2 tail -F &quot;$chan&quot; &amp; tailpid=$! trap &#x27;kill &quot;$tailpid&quot;&#x27; 0 while IFS=&#x27;&#x27; read -er line; do echo &quot;&lt;$nick&gt; $line&quot;; done &gt;&gt; &quot;$chan&quot; </code></pre> If you&#x27;re running this with multiple accounts, you may need to chmod a+w &#x2F;tmp&#x2F;yapchan, and if you&#x27;re using MacOS on the server, you may need to use a different filename since MacOS has a per-user private &#x2F;tmp.
评论 #9721740 未加载
rickralmost 10 years ago
talk has been around for like...30 years now:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Talk_(software)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Talk_(software)</a>
评论 #9718226 未加载
评论 #9717245 未加载
tunesmithalmost 10 years ago
I actually really miss the user experience of &#x27;talk&#x27; and &#x27;ytalk&#x27;. 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.
评论 #9716988 未加载
wycalmost 10 years ago
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&#x2F;tmux with a shared guest account:<p><pre><code> # 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 </code></pre> You can try it out with two terminals on your own.
评论 #9717196 未加载
alcarialmost 10 years ago
I seem to recall this being on HN a few months ago: <a href="https:&#x2F;&#x2F;github.com&#x2F;shazow&#x2F;ssh-chat" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;shazow&#x2F;ssh-chat</a>
2ton_jeffalmost 10 years ago
While linux x86_64 only, this is precisely why I built sshtalk -- <a href="https:&#x2F;&#x2F;2ton.com.au&#x2F;sshtalk" rel="nofollow">https:&#x2F;&#x2F;2ton.com.au&#x2F;sshtalk</a>, or just ssh 2ton.com.au to see for yourself, I leave it open as a public&#x2F;free service
评论 #9718151 未加载
评论 #9718207 未加载
评论 #9717294 未加载
Animatsalmost 10 years ago
Mandatory XKCD: <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;949" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;949</a>
评论 #9718222 未加载
评论 #9721141 未加载
rbcalmost 10 years ago
WRITE(1) is pretty much ubiquitous. Even Mac OS X has it. Very old school.
评论 #9719975 未加载
评论 #9717902 未加载
rdlalmost 10 years ago
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.<p>Maybe even spin up VMs on demand based on new hostname (if not seen before). First to claim = own. Some rate limiting function.<p>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&#x27;t be as bad.<p>No practical purpose, just fun.
评论 #9717581 未加载
giisalmost 10 years ago
We do this all the time, at-least for past 5 years or so while implementing our opensource project.<p>We login to same server to do :<p>#create a screen<p>screen -S chat<p>#Both of us will join the screen:<p>screen -x chat<p>#Now we can see each other typing. Make typing easier do:<p>write pts&#x2F;&lt;id&gt; username<p>#Make sure there is another login and use that pts &lt;id&gt; above.<p>After we typed our lines, to indicate I&#x27;m waiting for his response. I&#x27;ll adding 2 or 3 newlines.<p>That&#x27;s it ! :)Simple chat over ssh.
stock_toasteralmost 10 years ago
As pwg@ mentioned, talk is worth looking at. Check the man pages for `mesg` and `talk` and `write`.
peterwwillisalmost 10 years ago
You can&#x27;t connect ssh clients like you would modems. If the machines are on a public network you ssh to another person&#x27;s sshd, then use terminal chat programs. If you&#x27;re both behind a NAT, one of you needs to port-forward to your host&#x27;s sshd, or use STUN, TURN or ICE servers, or maybe just IPv6.<p>Once connected to someone&#x27;s host, use the Talk program (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Talk_%28software%29" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Talk_%28software%29</a>), or the Write program (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Write_%28Unix%29" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Write_%28Unix%29</a>), or use Netcat (<a href="http:&#x2F;&#x2F;hak5.org&#x2F;episodes&#x2F;haktip-82" rel="nofollow">http:&#x2F;&#x2F;hak5.org&#x2F;episodes&#x2F;haktip-82</a>) 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.
isedalmost 10 years ago
When you say &quot;they to me&quot; 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.<p>But when you mention &quot;wall(1)&quot; 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.<p>Option 2 would be less complex.<p>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.<p>Proof of concept:<p>Does Darwin have logger(1), syslogd(8) and &#x2F;etc&#x2F;syslog.conf(5)?<p>Decide where to log the messages, e.g., &#x2F;var&#x2F;log&#x2F;messages<p>Edit &#x2F;etc&#x2F;syslog.conf<p>Start syslogd<p>logger &quot;your message&quot;<p>less &#x2F;var&#x2F;log&#x2F;messages<p>less -F &#x2F;var&#x2F;log&#x2F;messages<p>tail -f &#x2F;var&#x2F;log&#x2F;messages<p>Messages have date, time, priority (if any) and hostname.<p>You said &quot;something basic&quot;; this is about as basic as it gets.
atxhxalmost 10 years ago
I remember netcat being installed on OS X by default, you could ssh in and run it or pipe the port through ssh.
评论 #9717001 未加载
NeutronBoyalmost 10 years ago
Not sure if it&#x27;s installed by default on OSX, but you could use screen&#x2F;byobu&#x2F;tmux to share a terminal session and type to each other.
atsalolialmost 10 years ago
man write<p><a href="http:&#x2F;&#x2F;ss64.com&#x2F;bash&#x2F;write.html" rel="nofollow">http:&#x2F;&#x2F;ss64.com&#x2F;bash&#x2F;write.html</a><p>You would need to run two instances of write : you would write to your friend and your friend would write to you.<p>Just press Enter twice when you are done with your turn (I.e. &quot;over&quot; as in, transmission over)
fsniperalmost 10 years ago
write anybody?? I must be too old for this shit then.<p>just write &lt;systemusername&gt; &lt;tty|ptsname&gt; enter message and quit with ctrl-d<p>from man page:<p><pre><code> 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&#x27;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&#x27;s turn to talk. The string ‘oo’ means that the person believes the conversation to be over.</code></pre>
评论 #9720322 未加载
danielhuntalmost 10 years ago
<a href="http:&#x2F;&#x2F;www.redbrick.dcu.ie&#x2F;~c-hey&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.redbrick.dcu.ie&#x2F;~c-hey&#x2F;</a><p><pre><code> 1. Install that on a machine. 2. Both SSH to the that machine machine. 3. Type: `hey &lt;username&gt;`, 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.</code></pre>
philprxalmost 10 years ago
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: <a href="https:&#x2F;&#x2F;github.com&#x2F;paramiko&#x2F;paramiko&#x2F;blob&#x2F;master&#x2F;demos&#x2F;demo_server.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;paramiko&#x2F;paramiko&#x2F;blob&#x2F;master&#x2F;demos&#x2F;demo_...</a>
chrisperalmost 10 years ago
You can also create a screen session. The other user logs into your ssh server and uses screen -x to attach to your terminal.
brajeshalmost 10 years ago
What&#x27;s wrong with using &#x27;wall&#x27;
andrewchambersalmost 10 years ago
it could be done with a fifo, I believe the command &quot;write&quot; also does this.
评论 #9716689 未加载
astazangastaalmost 10 years ago
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.
joshualmost 10 years ago
ssh to the same machine. $ mesg y $ talk &lt;otherusername&gt;
pwgalmost 10 years ago
man talk
cornellwrightalmost 10 years ago
An easy way is to just create a new screen (see the Unix command &quot;screen&quot;) 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.
agartneralmost 10 years ago
It might not be exactly what you&#x27;re looking for but you might take a look at <a href="https:&#x2F;&#x2F;github.com&#x2F;DSUOSS&#x2F;unix-chat" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DSUOSS&#x2F;unix-chat</a>.
lisperalmost 10 years ago
I&#x27;m working on a secure chat client that runs in a browser (so nothing to install). If you&#x27;re interested in being a beta tester send me your email address and I&#x27;ll send you an invite.
评论 #9718498 未加载
erikbalmost 10 years ago
I&#x27;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&#x27;d use a small database like sqlite or a logger because I want to make sure that the chatters don&#x27;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.<p>PS: Huge kudos for the question, btw. This is the kind of stuff that really improves your ability to use your system well.
thirdreplicatoralmost 10 years ago
User A logs into user B&#x27;s machine. User A or B types<p>screen -S chat<p>The other user types<p>screen -xr chat
naileralmost 10 years ago
Lots of custom solutions in this thread, but there&#x27;s already inbuilt commands for talking installed by default on every Unix box.<p>Log into a box, use &#x27;who&#x27; to see which terminal they&#x27;re using, and use &#x27;write&#x27; to send a message there.<p>Or be lazy and just use &#x27;wall&#x27; (write all) like I do.
ninjakeyboardalmost 10 years ago
Despite the fact that you both have SSH, you can still pick up the phone and call them. :) +1 for write. <a href="http:&#x2F;&#x2F;www.computerhope.com&#x2F;unix&#x2F;write.htm" rel="nofollow">http:&#x2F;&#x2F;www.computerhope.com&#x2F;unix&#x2F;write.htm</a>
silverwindalmost 10 years ago
netcat to the rescue!<p>You run:<p><pre><code> nc -l 5000</code></pre> They run:<p><pre><code> ssh [yourhost] nc localhost 5000 </code></pre> The only issue I see is that you apparently can&#x27;t get netcat to only listen on localhost so others could join in in theory.
评论 #9718275 未加载
评论 #9717894 未加载
userbinatoralmost 10 years ago
I&#x27;m not sure about OS X but most Linuxes have netcat installed.<p>There&#x27;s also OpenSSL s_client&#x2F;s_server for an encrypted connection, although you need to setup some certificates first.
评论 #9717675 未加载
c22almost 10 years ago
You could use this: <a href="https:&#x2F;&#x2F;github.com&#x2F;kryptographik&#x2F;ShuSSH" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kryptographik&#x2F;ShuSSH</a>
sturmehalmost 10 years ago
Run an irc bouncer like ZNC, they usually have a partyline plugin&#x2F;functionality that lets you chat as if you were on an irc server, but locally.
enterxalmost 10 years ago
check the following *nix utilities:<p>ssh one box to another, then:<p>who -uT &#x2F;&#x2F; show who is connected to a machine and will they recieve message sent with write or wall command<p>write &#x2F;&#x2F; 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.<p>wall &#x2F;&#x2F;send a msg to all of the logged in users<p>talk &amp; talkd &#x2F;&#x2F; client and server. (old school rulz!)
madaxe_againalmost 10 years ago
I&#x27;m surprised nobody has mentioned &quot;wall&quot;. Not great for chatting but damnably useful for unmissable comms with others on a box.
评论 #9718085 未加载
girish_halmost 10 years ago
You could ssh into another machine, run a screen session, launch a shell and start chatting inside the shell
resca79almost 10 years ago
try `write`:<p>&gt;usage: write user [tty]
gkoalmost 10 years ago
If you are using the same account: emacs --daemon (once), emacsclient -t (for everyone).
strathmeyeralmost 10 years ago
Have we forgotten about Zephyr?
评论 #9716847 未加载
fstutzmanalmost 10 years ago
Once you get ytalk running, the next step is to install colossal cave adventure.
plgalmost 10 years ago
unix command: kibitz<p>kibitz - allow two people to interact with one shell<p><a href="http:&#x2F;&#x2F;www.skrenta.com&#x2F;rt&#x2F;man&#x2F;kibitz.1.html" rel="nofollow">http:&#x2F;&#x2F;www.skrenta.com&#x2F;rt&#x2F;man&#x2F;kibitz.1.html</a>
yueqalmost 10 years ago
talk user@host
kpcyrdalmost 10 years ago
<p><pre><code> apt-get install nmap ncat --chat -lp 1234</code></pre>
maylialmost 10 years ago
You can use write or screen&#x2F;tmux.
alinspiredalmost 10 years ago
a shared screen session ? screen -x with any editor or just &#x27;cat&#x27; running
vectorEQalmost 10 years ago
tunnel netcat through SSH :D for fun, but probarbly not profit!
Shallealmost 10 years ago
open up a screen session and type whatever you want.
db48xalmost 10 years ago
install talk on one of your machines.
评论 #9717910 未加载
roka88almost 10 years ago
uyu
kichukualmost 10 years ago
This does not directly answer your question. But there is a way using third party software.<p>You can use &quot;<a href="https:&#x2F;&#x2F;telegram.org&quot;" rel="nofollow">https:&#x2F;&#x2F;telegram.org&quot;</a> telegram messsenger.<p>It works flawlessly from the cli.<p>Yes, you cannot use it if you don&#x27;t want your chats to pass through a third party server. But maybe you can try out the &quot;secret chat&quot; feature with auto destroy feature.<p>The traditional options have already been listed by others here. I just wanted to tell something which is easy to setup and also reliable.
评论 #9718790 未加载