I upgraded to Mountain Lion and something weitd is happening with accessing my computer via SSH. I am able to SSH into other boxes from my computer but I am not yet able to SSH into my laptop from other computers.

  • I have turned on remote sharing
  • I have tried the solution in altering the ssh_config and sshd_config in the /etc folder
  • I have turned off firewalls
  • I have tried this answer; says com.openssh.sshd: Already loaded

Still this problem persists. How can I fix this?

Reasons I need this fixed is mainly for secure copy via ssh. It is a pain to remember the realpath of a file on the cloud and access it from your box; although this is possible and has been how I have been surviving with this new Mountain Lion anomaly. But it would be easier to be able to SSH from the box which has the file into my laptop.

Thanks in advance for your help!

  • can you ssh to localhost (on the laptop) or does that also not work? What exactly does happen when you try to initiate an ssh connection? does it close immediately? does it ask you for a password? or does it simply time out? Did you try different user accounts (root@localhost, yourname@localhost, etc.)? – mreithub Jan 24 '13 at 2:01

OS X configuration

System Preferences → Sharing -> enable "Remote Login"

If you don't want to limit ssh access by account, select allow access for "All users".

Router Port Mapping

Kent Graves' answer actually reminds me of one thing.

Are you connecting behind a router? If so, you properly setup port forwarding before. If your IP changed (or become DHCP-assigned) after Mountain Lion upgrade, the port forwarding will no longer work. Check your OS X is using static IP, then either update the port forwarding rules on the router or change machine IP back as before.

Reverse SSH tunnel - Solve ssh problem without fixing the issue

  1. Testing

    If you can do the following on your OS X box, then this solution will work:

    ssh <osx-user>@localhost
  2. Connecting to cloud machine

    When using SSH to connect to a cloud machine, use the -R option to setup a reverse ssh tunnel back to the local machine:

    ssh <username>@<cloud-machine> -R <interface-IP:port on cloud machine>:localhost:22

    For example, connect to a cloud machine with the following command:

    ssh user@cloud-machine -R localhost:2000:localhost:22

    That sets up an SSH tunnel, from cloud-machine port 2000 to OS X machine port 22, which is the ssh server port.

  3. SCP/SSH back to OS X machince through tunnel

    SCP Example 1: copy from OS X box to cloud machine:

    scp -P 2000 <osx-user>@localhost:/path/* /var/www/

    SCP Example 2: copy from cloud machione to OS X box:

    scp -P 2000 /var/www/* <osx-user>@localhost:/path/

    SSH back to OS X machine with following command:

    ssh -p 2000 <osx-user>@localhost

    Note that SCP uses uppercase -P to specify the port, while SSH uses lowercase -p.

  • Does this help? – John Siu Jan 25 '13 at 15:43
  • Thanks for the detailed answer, I will come back to this in a bit. There is a chunk of information here and I would have to switch locations to properly test all of them So far, I can ssh into localhost. I know SSH is up. I am using OpenSSH—the one which ships with BSD; never changed it. However, from a different machine SSHing into mine is still impossible. – iGbanam Jan 27 '13 at 16:50
  • Are you able to ssh into your laptop from another machine in the same network(not going through a router). If not, that looks like a firewall issue. Though my last method will still able to get through it. – John Siu Jan 28 '13 at 15:28

I'm not familiar with OS X but the essentials are the same.

Are you sure ssh is running as a service even though you have it enabled?

Try running the OS X equivalent of netstat to see if port 22 is listening, if not then there is an issue with the service.

Second are you absolutely sure you only have one firewall? Even if your Host firewall is allowing port 22, if you are trying to SSH from outside your Local network than your gateway or router is probably blocking SSH as well because it also has a firewall. You will need to go into your router's configurations and allow access to port 22 on your network.

Even if your firewall is turned off and it is allowing connections to port 22. You must have a service listening on that port in order to create the connection.

Also where is the computer located that you are trying to create the SSH connection with? Is it on the Local Network, or are you connected to this machine via the internet?

I assume you have used SSH before but just to check what command are you using or what SSH Client are you using to create the connection? The format should be:

ssh <username>@<ip_address or hostname>

Whatever username you are using to connect to your machine the SSH server on that machine must be set up to allow that user to connect unless you have it set to All users like the other guy mentioned.

Here is a step by step walkthrough specifically for OS X Mountain Lion: http://www.ernieflores.net/osx-page-2/enable-remote-login-to-start-ssh-server-in-osx/

  • thanks for your answer. the issue still remains. I am conversant with SSH and I know the daemon is up and running. I am able to SSH into localhost via ssh <my_username>@localhost—no problem here. However, if I am on a different machine—say <your_username>@externalhost, I cannot into my machine; even if I use my explicit IP address. The connection times out – iGbanam Jan 27 '13 at 16:44
  • I am sort of behind a router right now, yes—my iPhone tethering. However, this issue still remains when I switch to Wi-Fi, change locations and even use an ethernet cable. Everything worked fine when I had Snow Leopard; not now, not with the Mountain Lion. – iGbanam Jan 27 '13 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.