Contents
How to connect to SSH from outside the network?
If you have control over the router (s) in the network (I assume you do), then you can set up simple port forwarding + translation. Choose a port number on the outside and map it to the internal network IP with port 22. You should then reach that internal port by accessing the external IP+port from outside.
Is there a way to block root SSH access?
That will block root access. You can then allow it for your local network with this: This assumes that your LAN gives IPs like 192.168.1.N, if not, change accordingly. Also, I suggest you add this at the end of /etc/ssh/sshd_config to make sure it does not conflict with other directives.
How to block SSH and FTP access to specific IP and network range?
For example, let us block the SSH and FTP access to host that has IP address 192.168.1.100 and network range 192.168.1.0. This method is same for CentOS 6.x and 7.x series.
How to block SSH access from external notwork?
This assumes that your LAN gives IPs like 192.168.1.N, if not, change accordingly. Also, I suggest you add this at the end of /etc/ssh/sshd_config to make sure it does not conflict with other directives.
How to allow SSH connections from Lan and Wan?
We can do this with the following commands. First, we block port 22 on the WAN interface with the command: Next we allow port 2222 on the WAN interface with the command: Once you have those two rules in place, test the connections from both the LAN and WAN, making sure to use port 2222 on the WAN side connection.
Can You SSH Raspi-Wan from outside the LAN?
Then, you can ssh raspi-wan from outside the LAN, or ssh raspi-lan from inside the LAN without faffing about with DNS servers or editing /etc/hosts for all users, or even needing to do anything as root.
Where do I set the port forwarding for SSH?
For the webserver you will need to set the port forwarding from port 80 on the external interface to your server and maybe port 443 if you want to include SSL/TLS connections. I also recommend using the SSH config file (~/.ssh/config) to make it easier when making either an internal or external connection. Add something like this: