Remote SSH connection

Networksshterminal

I want to connect my iMac remotely via ssh. Even though I can connect it locally, I can't do it remotely. When I try to connect remotely it refuses the connection.

port 22: Connection refused

I saw lots of discussions about the problem but w/o success. This is why I am opening a new thread.

I also disabled the firewall but still cannot connect. For diagnosing purposes, I executed netstat tupan and I see ssh local address as 192.168.1.33.ssh and Foreign address as 192.168.1.33.49883. Here is the output.

Proto Recv-Q Send-Q Local Address Foreign Address (state)

tcp4 0 0 192.168.1.33.ssh 192.168.1.33.49886 ESTABLISHED

tcp4 0 0 192.168.1.33.49886 192.168.1.33.ssh ESTABLISHED

tcp4 0 0 192.168.1.33.ssh 192.168.1.33.49884 ESTABLISHED

tcp4 0 0 192.168.1.33.49884 192.168.1.33.ssh ESTABLISHED

Could someone explain me what does this mean? Are those 49884 and 49886 are port numbers? Should I open new ports via port forwarding? And most importantly, could you guys explain me how can I connect remotely via ssh in layman terms please?

B.R.

Best Answer

Yes, the numbers 49884 and 49886 you see are indeed port numbers. However, they're not port numbers for the ssh service itself, but are the port numbers these specific clients have used for connecting. The numbers are essentially meaningless for you.

The usual problem that home users have with connecting remotely over SSH to their own computer is that their network is behind a NAT (Network Address Translation) router. Essentially this means that your router has a single public IP address, but allows multiple devices behind it to connect to the internet even though they have private IP addresses that are not "visible" on the internet.

The most common way to enable remote access over SSH is to add a port forward in the router. You'll need to port forward your remote IP port 22 to port 22 on the local IP of your iMac. How that is done depends on the exact router you have, but is usually explained in the manual or web interface help.