# Cannot connect using SSH



## fred974 (Dec 5, 2013)

Hi guys,

Until now, I was able to connect to my box using SSH on the standard port 22. For security reasons I decided to move to it to the different port 123456. On my LAN, when I tested the connection I was able to connect to the box using the newly specified port in sshd_config. But this morning when I tried to connect remotely, I did get the following error:

```
ssh: connect to host 82.31.xx.xxx port 12345: Connection refused
```

I looked at every setting on the router and the port forwarding is all set OK, and I even turned off the firewall but without success.

Could someone suggest what else I could try?

Fred


----------



## fred974 (Dec 5, 2013)

I might have sorted it. I didn't make any change to my PF firewall.

pf.conf:

```
sshd_port = "22"
pass in on $ext_if proto tcp to ($ext_if) port { $sshd_port } keep state
```

I will not be able to check this point until tonight so any other suggestion is very welcome


----------



## ShelLuser (Dec 5, 2013)

Just to rule out the obvious it might be useful to check the output of the sockstat command. That can help you to determine if sshd is actually listening to the port you expected it to.


----------



## fred974 (Dec 5, 2013)

Thank you @ShelLuser.

I'll check that before doing anything.

Fred


----------



## fred974 (Dec 6, 2013)

I ran the sockstat command and *I* could see that sshd is listening to my port. I updated the port number  in my pf.conf but I still cannot access it from outside the LAN. Inside the LAN it's all good.

Has anyone any more suggestions?


----------



## kisscool-fr (Dec 6, 2013)

Which external port is your router forwarding to your local machine for SSH?


----------



## fred974 (Dec 6, 2013)

Hi @kisscool-fr,

My router forwards port 19135 (my SSH port) to the IP address of the server. Have I set too high a range?

Fred


----------



## kisscool-fr (Dec 6, 2013)

No, the port number seems ok. 

Have you tried to listen on your local interface on the SSH server with tcpdump and try to connect from outside? It should tell you if your router is doing the job or not.


----------



## fred974 (Dec 9, 2013)

No I haven't but I will. I'm back on port 22 for now. I'll keep you posted.

Thank you all.


----------

