Can’t SSH into the Mac from Linux

Networkserver.appsshunix

I seem to be having a problem with trying to ssh into my Mac from a Linux desktop. I have two users on my Mac and can ssh between them, but other computers seem to be the problem.

I enabled remote login in System Preference > Sharing. It tells me to try "ssh username@192.168.x.x", but when I try that it does not work, likewise when I try using ssh -p22.

Later I generated an RSA file using ssh-keygen in the Linux desktop and added it into the Mac's authorized_keys file. Please note that I am able to ssh into the Linux desktop without any problem.And my firewall is off on the mac.

I do not even get prompted to enter the password, it just does nothing for some time and then later displays:-

ssh -p22 username@192.168.x.x

ssh: connect to host 192.168.x.x port 22: Connection timed out

I know I am connected to the internet. This is the verbose output:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 19: Applying options for *

debug1: Connecting to 192.168.x.x [192.168.x.x] port 22.

debug1: connect to address 192.168.x.x port 22: Connection timed out

ssh: connect to host 192.168.x.x port 22: Connection timed out

Does anyone have an idea what the problem may be? What other steps can I try to resolve this?

Best Answer

If you're getting timeouts, that has nothing to do with your authentication mechanism - whether password, or key based.

The timeout means either you can't connect to the Mac at all, or it's not accepting traffic on port 22 (the SSH port)

Some things to check -

  • Have you checked your firewall is off on the mac? System Preferences -> Security -> Firewall
  • Can you ping the Mac from the Linux desktop? A simple ping to the Mac will verify that they're on the same network and can communicate.

Fix your network issue before you try to fix your authentication.