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?)
On a Mac computer (earlier than macOS 11 Big Sur)Type "Network Utility" in the search field and select Network Utility. Select Port Scan, enter an IP address or hostname in the text field, and specify a port range. Click Scan to begin the test. If a TCP port is open, it will be displayed here.
Add a port forwarding rule for Port 22 and forward it to the internal IP address that you just mark down under TCP protocol. You should specify both the internal port and external port as 22. For some router, it allows you to specify a range of ports, set both the start port and end port to 22.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With