Macos – not able to SSH into the laptop

macososx-mountain-lionssh

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!

Best Answer

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.

Related Question