Connecting to Apache Server - apache

After I have created my apache server, and installed LAMP, I have portforwarded port 80, and am able to reach the server on any browser using my external IP. When I go to connect to the server through ssh using my terminal on my MacBook, I can only connect to it using the servers inet (IPv4) IP address, and not the external IP address using port 80, for example, I can connect to it using: ssh root#192.168.1.204, but I cannot connect to it using: ssh -p 80 root#'external ip address'
the error I get is: ssh_exchange_identification: Connection closed by remote host
PLEASE IF ANYONE CAN HELP! I have been struggling with this for days.
Thanks

SSH is port 22, you can't use it to connect to port 80. If you added the port 80 portion to your first command as well, you should see the same error.

Related

Forward server HTTP traffic to handle in another device via SSH Tunnel

I'm developing some webhook required direct access public domain to internal machine, thinking use SSH tunnel to forward data, or got alternative solution?
Hosting server & development machine are in same network
192.168.1.2/24 (Hosting server)
2nd machine is virtual mapping using forticlient firewall without static or dynamic IP in visible in hosting server, so is 1 way initial communication right now.
In this case possible to setup SSH tunnel forward all traffic from 192.168.1.2:80 to handle in development machine port 8080?
How to ssh syntax look like?
Thanks.
This could be done by setting up an SSH tunnel to the remote machine:
ssh -L localhost:80:localhost:8080 development-system
Every request to port 80 on the hosting-server is now forwarded to port 8080 on the development-system.
Please note, that the port 80 on the hosting-server could only be used, when you start the SSH command as root. Also note that the port 80 is only accessible from the hosting-server. To access the port 80 on the hosting-server from everywhere use the following:
ssh -L 80:localhost:8080 development-system
Be sure that you want that.
A good introduction to the topic could be found at
https://www.ssh.com/ssh/tunneling/example
https://unix.stackexchange.com/questions/115897/whats-ssh-port-forwarding-and-whats-the-difference-between-ssh-local-and-remot

Can't connect despite port forwarding

I have a Ubuntu Server 16.04 running on a machine in my local network.
The machine has static assigned IP and running apache2. There is no problem in connecting to it from my local network.
I have port-forwarding for ports 22 and 80 setup on my router to the IP address of the machine.
When I check the ports with my public IP address on sites like http://www.canyouseeme.org/ the result is that the ports are open. When I try to connect using my public IP address and using those ports the connections are refused.
I tried disabling firewall in the router and also on the machine, no result.
What else should I try? It seems that the server is getting no incoming connection when I check with netstat.
Just for troubleshooting purposes:
Setup port forwarding on port 22 and try to ssh into your server using the public IP? If it works, it means apache is refusing the connections and not your router or ISP
On your router, setup the server on the DMZ temporarily and check if it works
Add another port forwarding rule on your router to redirect all http requests on port 8000,for example, to port 80 internally, then try to access your server with http://[public_ip]:8000
Have you changed anything on the apache2.conf file? Also, explain how you are testing the connection, internally using the public IP or from the Internet?

Connect to SSH (port 22) through tunnel opened in PuTTY on Windows

I want to connect to a remote server (host1) that accessible only from it's private network.
Another server (host2) is accessible from the Internet.
I opened a tunnel to host2 using PuTTY and tested it's working with Firefox (also checked that I got different IP address).
How can I connect to host1 using the tunnel I created?
I tried to configure proxy (to the tunnel I created - localhost) in PuTTY but it's not working.
The error I got: "Server unexpectedly closed network connection"
Pay attention that the host is the computer name in the network.
You connect to the local tunnel end directly, no "proxy" setting is needed.
This typically means that you use "localhost" as a Host Name. And a port according to your tunnel configuration.
See my guide for tunneling SFTP/SCP session. It's for WinSCP, but just use PuTTY instead of WinSCP in section Connecting through the tunnel.

Able to connect to ssh server on any port using an ssh tunnel

I'm having a little problem with the ssh server running on an ubuntu server. I'm using key-pair authentication, and i'm able to connect just fine, but the problem is that i can connect on any port (using a tunnel), even though "Port 22" is defined in sshd_config. Why am i able to connect on any port? How can i stop ssh from listening to ports other than port 22?
In your screenshot Local Address column tells that you are listening on all interfaces at port 22 (e.g. 0.0.0.0:22). The Foreign Address column tells that anyone can connect from any ip from any port (e.g 0.0.0.0:*). And below the same for IPV6.
The connections are normally started from some random free high number port so it's ok to have wildcard in Foreign address. The only thing you care about is that there is a listener at local port 22. Just as you wanted.
You are connecting the port 22 first (as you don't specify anything else with -p switch) and then ssh directs data from port 54321 of one machine to 80 of the other. So, the path of the data is something like:
Machine A, port 54321 -> Machine A, port random -> Machine B, port 22, Machine B, port 80.
So the thing is, when not defined, it will connect to the ssh server on the default port 22. you can explicitly define the port using "-p xxxx" where xxxx is the ssh server port you want to connect to. When tunneling, the "local port" is the port on your computer you will connect to, and "remote port" is the port on the remote computer that the connection will end on. so its like this:
(localport->randomport)->->->->(sshport->remoteport)
sshport is defined by -p, and the default when not defined is port 22

firewall has blocked ssh. any wayarounds?

I want to connect to remote amazon aws service(EC2 instance) , and I would like to be able to ssh to it from my laptop while using the campus provided network (which has cyberoam firewall). However, they have pretty much every port blocked and ssh won't work. Is there anything i can do? does ssh run through port 80? I don't really know what to do .
All it says is :
ssh_exchange_identification: read: Software caused connection abort
ssh works elsewhere.
You can set your SSH server to use port 80 (or 443 if 80 is used for a webserver). Just check the configuration file of your ssh server for more details!