You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在macOS 10.13.1上启用Telnet服务器并配置为守护进程?

解决macOS High Sierra上telnetd无法监听连接的问题

我来帮你搞定这个telnetd启动的问题——我之前在macOS 10.13上也折腾过类似的情况,给你几个靠谱的方案:

1. 检查并修复launchd配置文件

从其他Mac复制的.plist文件很容易出现权限或格式问题,这是最常见的原因。建议你重新创建一个标准的配置文件,放在系统级目录下(比用户目录更适合守护进程):

首先,创建/Library/LaunchDaemons/com.telnetd.plist文件,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.telnetd</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/Cellar/telnetd/54.50.1/sbin/telnetd</string>
        <string>-debug</string> <!-- 先开调试模式方便排查,正常运行后可移除 -->
    </array>
    <key>inetdCompatibility</key>
    <dict>
        <key>Wait</key>
        <false/>
    </dict>
    <key>Sockets</key>
    <dict>
        <key>Listeners</key>
        <dict>
            <key>SockServiceName</key>
            <string>telnet</string>
            <key>SockType</key>
            <string>stream</string>
            <key>SockProtocol</key>
            <string>tcp</string>
        </dict>
    </dict>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

然后设置正确的权限(必须是root拥有,权限644):

sudo chown root:wheel /Library/LaunchDaemons/com.telnetd.plist
sudo chmod 644 /Library/LaunchDaemons/com.telnetd.plist

接着重新加载配置:

sudo launchctl unload /Library/LaunchDaemons/com.telnetd.plist  # 先卸载旧配置(如果有的话)
sudo launchctl load -w /Library/LaunchDaemons/com.telnetd.plist

之后用lsof -i :23检查是否有进程监听23端口,或者直接用telnet localhost测试连接。

2. 手动启动telnetd排查基础问题

先绕开launchd,直接手动启动telnetd,确认程序本身能正常运行:

sudo /usr/local/Cellar/telnetd/54.50.1/sbin/telnetd -debug -p 23

如果启动后没有报错,尝试从本地或另一台机器用telnet localhost 23连接。如果手动启动能成功,那问题肯定出在launchd的配置上,回到第一个方法仔细核对plist内容。

3. 使用Homebrew Services管理(更省心的方式)

Homebrew自带的services工具可以帮你自动管理后台服务,省去手动配置plist的麻烦:

如果还没装这个工具,先执行:

brew tap homebrew/services

然后直接启动telnetd:

brew services start telnetd

你可以用brew services list查看服务状态,确认telnetd是否在运行。这个方法会自动生成正确的launchd配置,稳定性更高。

4. 借助inetd(备选方案)

如果上面的方法都不行,可以尝试安装inetd,通过它来触发telnetd的启动:

brew install inetutils

编辑/usr/local/etc/inetd.conf,添加以下内容:

telnet  stream  tcp  nowait  root  /usr/local/Cellar/telnetd/54.50.1/sbin/telnetd  telnetd

然后启动inetd服务:

brew services start inetutils

这样inetd会在收到telnet连接请求时自动启动telnetd。

最后提醒:调试没问题后,记得把plist里的-debug参数移除,重启服务即可。

内容的提问来源于stack exchange,提问作者ken8311

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:24:12