How do I set up SSH into my Mac with Lion?

I recently bought a Macbook Air with Lion. I would like to ssh into my Mac at work. How do I set this up?

I have a private and public key, so I will likely use that option to allow access into my mac.


Solution 1:

Apple -> System Preferences -> Sharing -> Remote Login.

Solution 2:

If you want to be able to SSH from work to home, you'll need to do the following:

  • Get the external IP address of your home network. You can obtain this by going to this website. If you ISP changes your IP frequently, you'll have to use something like Dyn DNS.

  • Open port 22 on your firewall/router and point it to the local IP address of the Mac you want to connect to. Instructions for this step vary on your firewall/router model. You may want to set up a DHCP reservation for this Mac so the internal IP address doesn't change.

  • On the Mac your want to connect to, open System Preferences → Sharing and enable Remote Login.

  • You should now be able to run the command ssh [email protected], replacing "user" with the home computer's username and the "ip.of.your.mac" with the home IP address.

Solution 3:

  1. Simply activate the option in Preferences : "Remote login".

  2. Access your mac :

    ssh [email protected]