I have a server machine (A) which has ssh installed, along with a webserver.

How do I forward the port with the webserver to my local machine (B).

I should be able to browse to `http://localhost:forwardedport` 

Is this LOCAL or REMOTE port fowarding? Here's what I've tried.

```
ssh -L 8888:name.dnydns-server.com:8888 localhost

ssh -L 8888:localhost:8888 name.dnydns-server.com

and both of those with username@name.dnydns-server.com

```

What am I doing wrong?

**EDIT**: The answers given were factually correct and explained the usage of port forwarding. It turned out that I was using the correct command, rather there was a firewall rule which prevented me from connecting to port 8888 FROM the server itself. I figured this out when I tried to connect to the website while sshed into the remote server.
['https://superuser.com/questions/667040', 'https://superuser.com', 'https://superuser.com/users/35728/']
I guess you first need to get clear on some terms I'll use:

**Client** means the machine where you start ssh. This machine is refered to by "local".

**Server** means the machine you want to connect to with ssh. This machine is refered to by "remote".

**Local port forwarding** with ssh means you connect from your client to your server and thereby open a tunnel so that another program on your client can connect via a local port to a host&port on the server site. The option for this is -L local\_port:remote\_machine:remote\_port.

**Remote port forwarding** with ssh means you connect from your client to your server and thereby open a tunnel so that a program on your server can connect via a port on the server to a host&port on the client site. The option for this is -R remote\_port:local\_machine:local\_port.

If I understand you correctly, you want a local forwarding, e.g. create a connection to your server name.dnydns-server.com and then connect with your local browser to port 8888 on name.dnydns-server.com.

The following command from your list should actually do what you want:

```
ssh -L 8888:localhost:8888 name.dnydns-server.com

```

The first 8888 is the port on your client that your additional program (browser) can connet to.

The "localhost" in that line is seen from the end of the tunnel, that is on the server (name.dnydns-server.com). There localhost is the machine itself so it's the one you want. (You could place a different name on the network of your server there to access that)

The second 8888 is the port you want to connect to on the server site. If you run your webserver on the standard port 80, you'll have to change this to 80.

name.dnydns-server.com is the name of your ssh server where you connect to, which is then the endpoint of the tunnel.

I don't know why this line didn't work for you though. Did you quit the ssh? It has to stay connected the whole time for the tunnel to work. Default port on the webserver? Webserver not running?

**Edit:** I changed the definition of "client" and "server" to clarify things, so some of the comments don't apply anymore and refer to deleted content.
I am presuming that the server has sshd installed, and listening on the well known default port (22), and that the web server is listening on the well-known default port (80). The assumption is that the server is the server (A) is the 'conduit' through which you want to tunnel to get to the web server. Here's what you need to 'tell' ssh in this case:

```
ssh -L <local port to point your browser toward>:<host name or IP of the web server>:<port that the web server is listening on> <valid user on server>@<server name or ip address>

```

So, here's what I think it should look like based on what I think you're trying to do:

```
ssh -L 8888:web.server.dyndns-server.com:80 youruserid@yourserver

```

Do this, then point your browser to localhost:8888.