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

标签 macos ssh ssh-keys

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

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

我已经生成了一个 key 并将其放入我的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?或者我可能会遇到另一个问题(也许生成的 key 不正确?)

最佳答案

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

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.

这些说明复制自 Enable SSH in Mac OS X ,但我想确保它们不会消失并提供快速访问。

关于macos - 如何在 OS X 10.6.7 中打开端口 22,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6313929/

相关文章:

Github 部署 key : How do I authorize more than one repository for a single machine?

linux - 使用 imagemagick 将剪切/裁剪标记添加到 pdf

macos - 添加为 subview 的 NSView 不显示

c++ - sftp_read 从文件读取时会跳转大块字节

linux - 使用 bash 脚本输入 ssh 密码,没有那个文件或目录

git - 多个 github 帐户 : what values for Host in . ssh/config?

从docker容器内部git克隆项目

mysql - Mac OSX 10.2 上的 MariaDB 10.1.22 - 在 my.cnf 中启用常规查询日志

python - 无法在 MacOS 11.1 上使用 pyenv 安装带有共享库的 Python 构建

hadoop - 通过 Chef 在ec2中设置ssh无密码