# SSH only connected though port 22?

## pstar

Hi, I am trying to set up my home PCs so I can ssh from outside. But when I tried ssh to my University

serve and ssh back, it will get  "Connection refused" errors unless I set my sshd to use port 22 and forward 

port 22 in my modem to my home PCs. 

Even I set the port forwarding forward port other port like 1022(Public) to 22(private), it still wouldn't work?

Interesting thins is that if I test from port testing site, it will tell that my port 1022 is opened, only ssh wouldn't go thought, why? 

Other questions, may or maybe not related:

1. I use a Linksys WRT54G as hub, I think that is the correct term. I put modem ethernet, my PCs ethernet cables all into my ethernet port 1,2,3,4 

and leave the Internet port empty as I found its easier to manage, not need to set up IPs , port forwarding in modem and router. So I assume nothing

need to setup here?

2. Do I have to forward both UPD and TCP port for SSH and HTTP to working?

----------

## Raniz

You need to forward ports on your router, otherwise you can't reach the computers behind it.

What command are you executing to connect to your computer when you've enabled port forwarding from 1022(Public) to 22(private)? If you're using the regular ssh user@host it won't work since SSH uses port 22 as default. If you want it to connect to a different port you need to specify it with the -p option, like this: ssh -p 1022 user@host.

You should also make sure that SSHD is listening on port 22 and not port 1022 since the router is set to forward incoming traffic on port 1022 to port 22 on your computer.

SSH is TCP only afaik, so no need to forward UDP.

----------

## pstar

Raniz, I don't understand, but seems like I have two separate post sessions.

But anyway, I did port forwarding in my router/modem combo, and I am using

```

ssh -p 1022 user@hostip

```

but it didn't work.

----------

## Raniz

I couldn't really understand your router setup, but you do have the modem connected to your WAN port and your computers connected to the other four ports, right?

----------

## pstar

```
                   

                                -------------------------------------- 

                               |           WRT54G                       |

                               |WAN   |     Port: 1       2    3    4|

                               --------------------------------------

                                 Empty              |         |          |

                                                      |         |          |

                                                      |         |          |

                                                    PC 1   PC 2  ADSL Modem/Router

```

That's my setup, I choose that setup basically because it's easier to manage port forwarding.

Edit: Forum doing some auto formatting thing, I give up. If the drawing are not very clear, I leave out WAN/Internet port and connectiing

everything to port 1, 2  and 4.

----------

## Raniz

When you set up port forwarding your router forwards incoming ports on the WAN interface to one of your local computers. In your setup that won't work since the WAN interface isn't connected to the internet. Your setup is using the router as a switch - which usually isn't that popular with ISPs.

I recommend that you plug your modem into the WAN port and then go with the port forwarding method.

----------

## pstar

 *Raniz wrote:*   

> When you set up port forwarding your router forwards incoming ports on the WAN interface to one of your local computers. In your setup that won't work since the WAN interface isn't connected to the internet. Your setup is using the router as a switch - which usually isn't that popular with ISPs.
> 
> I recommend that you plug your modem into the WAN port and then go with the port forwarding method.

 

Yes, I think I am using my WRT54G router as a switch. But modem/Router should doing forwarding isn't it?

Port 1022 is opened from outside. I am not sure how to check/setup my WRT54G as it seems don't understand any devices connected to

it as IP level?

----------

## Raniz

 *pstar wrote:*   

>  *Raniz wrote:*   When you set up port forwarding your router forwards incoming ports on the WAN interface to one of your local computers. In your setup that won't work since the WAN interface isn't connected to the internet. Your setup is using the router as a switch - which usually isn't that popular with ISPs.
> 
> I recommend that you plug your modem into the WAN port and then go with the port forwarding method. 
> 
> Yes, I think I am using my WRT54G router as a switch. But modem/Router should doing forwarding isn't it?
> ...

 

As I said, port forwarding only works when you've got your router connected to the internet on the WAN port.

----------

## pstar

 *Raniz wrote:*   

> 
> 
> As I said, port forwarding only works when you've got your router connected to the internet on the WAN port.

 

I still didn't see the WRT54G matter here, but to make it simple for both of us, I now took it out and put a simple switch here instead. 

The problem is same.

----------

## pstar

I am thinking about it's probably the University internet firewall. Does anyone know some free ssh servers I can ssh to and test back my 

server setup at home? Or other suggestions?

----------

## pstar

Thank you very much guys, it's my university's fault, now they block every port beside 80 and 22 by default. From other server it is working..

----------

