在 Mac 上以单用户模式启用 SSH

Ral*_*tor 10 networking ssh command-line macos

我有一台 iMac,由于严重的硬件损坏,我只能在单用户模式下访问它。我用以太网电缆将另一台计算机连接到它。我想通过 SSH 远程登录 iMac。iMac 运行的是 OS X 10.6.4。

我遇到了类似的答案,但我尝试的总是失败。

我试过了systemsetup -setremotelogin on,它返回以下错误消息:

systemsetup[63:903] setInetDServiceEnabled failed for ssh because authorizationRef is NULL!
Run Code Online (Sandbox Code Playgroud)

虽然launchctl load -w /System/Library/LaunchDaemons/ssh.plist给出:

DNSServiceRegister("ssh"): -65563
DNSServiceRegister("sftp-ssh"): -65563
bind(): Can't assign requested address
launch_msg(): Socket is not connected
launchctl: CFURLWriteDataAndPropertiesToResource(/var/db/launchd.db/com.apple.launchd/overrides.plist) failed: -10
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

Bla*_*ing 8

看起来你需要加载更多的 plists:

launchctl load /System/Library/LaunchDaemons/com.apple.kextd.plist
launchctl load /System/Library/LaunchDaemons/com.apple.notifyd.plist
launchctl load /System/Library/LaunchDaemons/com.apple.configd.plist
launchctl load /System/Library/LaunchDaemon/com.apple.DirectoryServices.plist
Run Code Online (Sandbox Code Playgroud)

然后做你之前尝试过的:

launchctl load -w /System/Library/LaunchDaemons/ssh.plist
systemsetup -setremotelogin on
Run Code Online (Sandbox Code Playgroud)

之后,我认为您可以简单地将以太网电缆插入两台计算机以创建一个临时网络。ifconfig en0 | grep inet在目标机器上应该会得到它的 IP 地址,然后你就完成了。:)