[pi4.677] $ cd /etc/ssh
[pi4.678] $ diff sshd_config.orig sshd_config
121a122,133
>
> # We don't listen on the Internet...
> ListenAddress 192.168.1.252
> ListenAddress 192.168.1.254
> # We need to allow root login for rsnapshot backup server
> PermitRootLogin prohibit-password
> # We want login via ssh with keys only...
> PubkeyAuthentication yes
> PasswordAuthentication no
> ChallengeResponseAuthentication no
I'd do both. Just to be sure. It's always possible to make a mistake in the firewall that would allow the traffic again. Or a mistake in sshd_config that would make it listen on all IP addresses. By setting both you reduce that risk.Blocking the WAN or restricting port22 to LAN.
pf
and see who you want to keep out, period. If you also try to ask the firewall to pay attention to specific ports and services, outbound packets as well as in - that creates difficult-to-troubleshoot complexity.I agree and did not want to stomp on your correct answer.The original question of listening for "ssh but only on lan interfaces" is a different issue to how you configure your Internet firewall.
That's my fault. My firewall runs on Debian Linux, and I just cut'n'pasted the ssh config diffs.Everybody seems to be getting the config file wrong. The SSH server settings file is /etc/ssh/sshd_config
My firewall runs on a Raspberry Pi and boots from an SD card. SD cards have poor durability. I always mount writable file systems (especially /var/log) on a USB stick (which is fast enough for my situation). So we have a similar issue with write cycles, if some orders of magnitude different in the speed department.My main reason for using the NanoBSD version was to preserve SSD write cycles.
I have been writing and perfecting my own firewall for the last 10 years. It's illuminating, and fun. But I would never recommend that sort of insanity to anyone else...Freeing myself of a pre-built firewall.
I agree. I tried the crutch approach here too.that sort of insanity
Instead of having a pratfall, you can study up on Pratt parsing, very useful for firewallsI agree. I tried the crutch approach here too.
security/fwbuilder.
pf rules via wizzard. What could go wrong!!
(Except there is no template for what I want so you have to learn Pf rule ordering anyway).
I did'nt think I would need to use tables for my simple setup but I drifted there anyway.
I do feel like a labotomy is in order and I am still not live with my setup.
Security is always a compromise. With an infinitely large team of administrators and infinite time, you can make a system perfectly secure. Consider the price you'll pay for that though: Not only the salaries of all those people, and the long wait times while they work on securing things. But also their constant intrusiveness (security is usually done at the cost of convenience), and the downtime (like all systems, security isn't perfectly reliable).
So the art of doing security is (like all of engineering) is the art of compromise: What can I do that has low cost, low complexity, and is pretty good? How many of these things can I layer together? Of all the possible approaches, which has the best cost/benefit? Given that no approach is ever 100% reliable and safe, how many layers do I need to implement, until I feel comfortable?
In that spirit: Editing /etc/ssh/sshd.conf to turn off unwanted sources of ssh connections is relatively easy. The cost is that one has to sit down (for a minute or an hour, depending on experience) to read and understand the sshd_config(5) man pages. Decent security for low cost. Problem is: Now there are explicit addresses in that config file, and if the network is reconfigured, things will go pear-shaped. The opportunity is that one should also think through many of the other options in that config file (for example: Should root login be allowed? Should passwords or keys or both or neither be allowed?), and think about ssh security holistically.
On the other side, editing /etc/pf.conf is also an excellent idea. But the effective way to do it is (as gpw928 said above) is not to open or close on port, but to think about the host's whole security posture: what services does it need to provide? Which of those services are actually really worth the cost of making them secure enough? Who is likely to be attacking, and what might they be after? Is it even worth it to secure certain things, while other things need to be (unfortunately by their nature) wide open? For example, for a machine that is strictly on an internal network that is secure, blocking things by default is just creating a hairball for no benefit. And consider that pf.conf also depends on network configuration (it tends to have both interface names and address ranges explicitly written in it).
And finally, consider other layers. For example, I really like the proposal that gpw928 also mentioned: Move ssh to a different port. It is not secure against determined attackers, but it means that the dumb script kiddies that only probe port 22 have no chance.
In the hope that people read them.you're always writing essays, why?
There is a website for that.
Pick your firewall at the bottom