How do I open port 22 in OS X 10.6.7
Asked Answered
B

6

93

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?)

Bellis answered 11/6, 2011 at 3:49 Comment(0)
P
198

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.

Perpetuity answered 11/6, 2011 at 3:52 Comment(4)
I can't understand what you have done. Exact where sharing icon is available. please, help me.Platte
It's under System Preferences, available under the Apple menu at the top.Perpetuity
Also make sure you have "Allow Access For all Users" if you are not the admin.Bushwhack
FYI: 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.Malloy
D
37

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

enter image description here

Duodecimal answered 4/2, 2017 at 7:40 Comment(1)
Link is broken.Evidentiary
H
16

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.

Heiress answered 24/10, 2019 at 11:43 Comment(0)
J
7

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.

Jennet answered 1/4, 2021 at 4:40 Comment(0)
R
4

As per macOS 10.14.5, below are the details:

Go to

system preferences > sharing > remote login.

Radarman answered 20/1, 2020 at 7:19 Comment(1)
This is easiest way!Thank you !Attach
C
0

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  
Coddle answered 15/5, 2016 at 5:54 Comment(1)
I followed this process and got '34720 0 com.openssh.sshd.long_string_of_digits_and_numbers', but 'ssh username@IP_address' still gives me 'ssh: connect to host IP_address port 22: Connection refused'Historied

© 2022 - 2024 — McMap. All rights reserved.