TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

327 点作者 biturd将近 10 年前
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 条评论

JamesMcMinn将近 10 年前
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 未加载
kragen将近 10 年前
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 未加载
rickr将近 10 年前
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 未加载
tunesmith将近 10 年前
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 未加载
wyc将近 10 年前
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 未加载
alcari将近 10 年前
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_jeff将近 10 年前
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 未加载
Animats将近 10 年前
Mandatory XKCD: <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;949" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;949</a>
评论 #9718222 未加载
评论 #9721141 未加载
rbc将近 10 年前
WRITE(1) is pretty much ubiquitous. Even Mac OS X has it. Very old school.
评论 #9719975 未加载
评论 #9717902 未加载
rdl将近 10 年前
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 未加载
giis将近 10 年前
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_toaster将近 10 年前
As pwg@ mentioned, talk is worth looking at. Check the man pages for `mesg` and `talk` and `write`.
peterwwillis将近 10 年前
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.
ised将近 10 年前
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.
atxhx将近 10 年前
I remember netcat being installed on OS X by default, you could ssh in and run it or pipe the port through ssh.
评论 #9717001 未加载
NeutronBoy将近 10 年前
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.
atsaloli将近 10 年前
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)
fsniper将近 10 年前
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 未加载
danielhunt将近 10 年前
<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>
philprx将近 10 年前
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>
chrisper将近 10 年前
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将近 10 年前
What&#x27;s wrong with using &#x27;wall&#x27;
andrewchambers将近 10 年前
it could be done with a fifo, I believe the command &quot;write&quot; also does this.
评论 #9716689 未加载
astazangasta将近 10 年前
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将近 10 年前
ssh to the same machine. $ mesg y $ talk &lt;otherusername&gt;
pwg将近 10 年前
man talk
cornellwright将近 10 年前
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.
agartner将近 10 年前
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>.
lisper将近 10 年前
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 未加载
erikb将近 10 年前
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.
thirdreplicator将近 10 年前
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
nailer将近 10 年前
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.
ninjakeyboard将近 10 年前
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>
silverwind将近 10 年前
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 未加载
userbinator将近 10 年前
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 未加载
c22将近 10 年前
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>
sturmeh将近 10 年前
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.
enterx将近 10 年前
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_again将近 10 年前
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_h将近 10 年前
You could ssh into another machine, run a screen session, launch a shell and start chatting inside the shell
resca79将近 10 年前
try `write`:<p>&gt;usage: write user [tty]
gko将近 10 年前
If you are using the same account: emacs --daemon (once), emacsclient -t (for everyone).
strathmeyer将近 10 年前
Have we forgotten about Zephyr?
评论 #9716847 未加载
fstutzman将近 10 年前
Once you get ytalk running, the next step is to install colossal cave adventure.
plg将近 10 年前
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>
yueq将近 10 年前
talk user@host
kpcyrd将近 10 年前
<p><pre><code> apt-get install nmap ncat --chat -lp 1234</code></pre>
mayli将近 10 年前
You can use write or screen&#x2F;tmux.
alinspired将近 10 年前
a shared screen session ? screen -x with any editor or just &#x27;cat&#x27; running
vectorEQ将近 10 年前
tunnel netcat through SSH :D for fun, but probarbly not profit!
Shalle将近 10 年前
open up a screen session and type whatever you want.
db48x将近 10 年前
install talk on one of your machines.
评论 #9717910 未加载
roka88将近 10 年前
uyu
kichuku将近 10 年前
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 未加载