macos 如何在 OS X 10.6.7 中打开端口 22
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6313929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I open port 22 in OS X 10.6.7
提问by David Erwin
I am trying to open port 22 on osx so I can connect to localhost using ssh. This is my current situation:
我正在尝试在 osx 上打开端口 22,以便我可以使用 ssh 连接到本地主机。这是我目前的情况:
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:
我已经生成了一个密钥并将它扔到我的 authorized_keys 文件中,如下所示:
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.
“网络实用程序”端口扫描确认 22 个(令人惊讶的是 23 个)已关闭。
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.
上下文:我正在努力在本地设置 Hadoop。在我的配置中,我在 localhost:####s 上运行服务,并且需要通过 ssh 打开与它们的通信。
How can I open 22? or could I be up against another issue (improperly generated key perhaps?)
我怎样才能打开22?或者我可能会遇到另一个问题(可能是生成的密钥不正确?)
回答by Haukman
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.
Apple Mac OS X 操作系统默认安装了 SSH,但未启用 SSH 守护程序。这意味着在启用它之前,您无法远程登录或进行远程复制。
要启用它,请转到“系统偏好设置”。在“互联网和网络”下有一个“共享”图标。运行那个。在出现的列表中,选中“远程登录”选项。在 OS X Yosemite 及更高版本中,不再有“互联网和网络”菜单;它已移至帐户。共享菜单现在在主系统偏好菜单上有自己的图标。(感谢@AstroCB)
这会立即启动 SSH 守护程序,您可以使用您的用户名远程登录。“共享”窗口在底部显示要使用的名称和 IP 地址。您还可以使用终端应用程序中的“whoami”和“ifconfig”找到这一点。
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.
这些说明是从在 Mac OS X 中启用 SSH复制的,但我想确保它们不会消失并提供快速访问。
回答by rsinha
回答by Yogesh Kumar
There are 3 solutions available for these.
有 3 种解决方案可用于这些。
1) Enable remote login using below command - sudo systemsetup -setremotelogin on
1) 使用以下命令启用远程登录 - sudo systemsetup -setremotelogin on
2) In Mac, go to System Preference -> Sharing -> enable Remote Login that's it. 100% working solution
2) 在 Mac 中,转到“系统偏好设置”->“共享”->“启用远程登录”。100% 工作解决方案
3) Final and most important solution is- Check your private area network connection . Sometime remote login isn't allow inside the local area network.
3)最后也是最重要的解决方案是- 检查您的专用区域网络连接。有时在局域网内不允许远程登录。
Kindly try to connect your machine using personal network like mobile network, Hotspot etc.
请尝试使用移动网络、热点等个人网络连接您的机器。
回答by Pramod Patil
As per macOS 10.14.5, below are the details:
根据 macOS 10.14.5,以下是详细信息:
Go to
去
system preferences > sharing > remote login.
系统偏好设置 > 共享 > 远程登录。
回答by Nag Arvind Gudiseva
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