如何在 OS X 10.6.7 中打开端口 22

发布于 2024-11-14 17:32:38 字数 498 浏览 3 评论 0原文

我正在尝试在 osx 上打开端口 22,以便可以使用 ssh 连接到本地主机。这是我目前的情况:

ssh localhost
ssh: connect to host localhost port 22: Connection refused

我已经生成了一个密钥并将其放入我的authorized_keys 文件中,如下所示:

sh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

“网络实用程序”端口扫描确认 22 个(令人惊讶的是 23 个)已关闭。

背景:我正在努力在本地设置 Hadoop。在我的配置中,我在 localhost:####s 上运行服务,并且需要通过 ssh 打开与它们的通信。

怎么才能打开22呢?或者我可能会遇到另一个问题(也许生成的密钥不正确?)

I am trying to open port 22 on osx so I can connect to localhost using ssh. This is my current situation:

ssh localhost
ssh: connect to host localhost port 22: Connection refused

I have generated a key and tossed it into my authorized_keys file like so:

sh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

A "Network Utility" port scan confirms that 22 (and surprisingly 23) are closed.

Context: I am working on getting Hadoop set up locally. In my configuration, I am running services on localhost:####s and need to open communications to them via ssh.

How can I open 22? or could I be up against another issue (improperly generated key perhaps?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

蛮可爱 2024-11-21 17:32:38

我认为你的端口可能是开放的,但你没有任何东西可以监听它。

Apple Mac OS X 操作系统默认安装了 SSH,但
SSH 守护进程未启用。这意味着您无法远程登录或
执行远程复制,直到启用它。

要启用它,请转到“系统偏好设置”。在“互联网和互联网”下网络”中有一个“共享”图标。运行那个。在列表中
出现时,选中“远程登录”选项。在 OS X Yosemite 及更高版本中,不再有“互联网和互联网”。网络菜单;它已移至帐户。现在,“共享”菜单在主“系统偏好设置”菜单上有自己的图标。 (谢谢@AstroCB)

这会立即启动 SSH 守护进程,您可以远程登录
使用您的用户名。 “共享”窗口底部显示名称
和要使用的 IP 地址。您还可以使用“whoami”和
来自终端应用程序的“ifconfig”。

这些说明是从 在 Mac OS X 中启用 SSH 复制的,但我想要确保它们不会消失并提供快速访问。

I think your port is probably open, but you don't have anything that listens on it.

The Apple Mac OS X operating system has SSH installed by default but
the SSH daemon is not enabled. This means you can’t login remotely or
do remote copies until you enable it.

To enable it, go to ‘System Preferences’. Under ‘Internet & Networking’ there is a ‘Sharing’ icon. Run that. In the list
that appears, check the ‘Remote Login’ option. In OS X Yosemite and up, there is no longer an 'Internet & Networking' menu; it was moved to Accounts. The Sharing menu now has its own icon on the main System Preferences menu. (thx @AstroCB)

This starts the SSH daemon immediately and you can remotely login
using your username. The ‘Sharing’ window shows at the bottom the name
and IP address to use. You can also find this out using ‘whoami’ and
‘ifconfig’ from the Terminal application.

These instructions are copied from Enable SSH in Mac OS X, but I wanted to make sure they won't go away and to provide quick access.

小糖芽 2024-11-21 17:32:38

我正在使用 OSX 10.11.6 和 这篇文章对我有用。

输入图片描述这里

I'm using OSX 10.11.6 and this article works for me.

enter image description here

那一片橙海, 2024-11-21 17:32:38

有 3 种解决方案可用于解决这些问题。

1)使用以下命令启用远程登录
- sudo systemsetup -setremotelogin on

2) 在 Mac 中,转到系统偏好设置 ->分享->启用远程登录
就是这样。 100% 有效的解决方案

3) 最终也是最重要的解决方案是 - 检查您的专用区域网络连接。有时局域网内不允许远程登录。

请尝试使用移动网络、热点等个人网络连接您的机器

There are 3 solutions available for these.

1) Enable remote login using below command
- sudo systemsetup -setremotelogin on

2) In Mac, go to System Preference -> Sharing -> enable Remote Login
that's it. 100% working solution

3) Final and most important solution is - Check your private area network connection . Sometime remote login isn't allow inside the local area network.

Kindly try to connect your machine using personal network like mobile network, Hotspot etc.

娇柔作态 2024-11-21 17:32:38

如果您尝试从终端窗口启用远程登录,您可能会遇到“完整磁盘权限问题”。或者,您可以从Apple Icon -> 启用它。系统偏好设置->共享

我正在使用 Mac-bigSur,这就是我在我的计算机上启用它的方法

在此处输入图像描述

您还可以允许特定用户访问。

If you try to enable remote login from a terminal window, you may get a "full disk permission issue". Alternatively, You can enable it from Apple Icon -> System Preferences -> Sharing

I am using Mac-bigSur and this is how I enable it on my machine

enter image description here

You can allow access to specific users also.

爱人如己 2024-11-21 17:32:38

根据 macOS 10.14.5,详细信息如下:

转到

系统偏好设置>分享>远程登录。

As per macOS 10.14.5, below are the details:

Go to

system preferences > sharing > remote login.

扛刀软妹 2024-11-21 17:32:38

我无法解决问题;然后我执行了以下操作,问题得到解决:
请参阅此处

sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist  
    (Supply your password when it is requested)   
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist  
ssh -v localhost  
sudo launchctl list | grep "sshd"  
    46427   -   com.openssh.sshd  

I couldn't solve the problem; Then I did the following and the issue was resolved:
Refer here:

sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist  
    (Supply your password when it is requested)   
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist  
ssh -v localhost  
sudo launchctl list | grep "sshd"  
    46427   -   com.openssh.sshd  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文