Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Everyday people try to hack in with ssh.

    Scheduled Pinned Locked Moved Firewalling
    18 Posts 9 Posters 12.8k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      skear
      last edited by

      I get tons of SSH hack attempts on my pfSense box and my linux server as well.  Most of the attacks come from zombie computers that are part of a botnet. There are a few things you can do to prevent them.

      1. Change the default ssh port - this will confuse most of the bots that look on port 22
      2. Setup key based authentication - this may not be feasible

      I find it to be much more fun to blacklist the attackers and report them to their ISP.

      If you want to go this route you can install Denyhosts, pfSense 1.2.3 has a package for it, 2.0 does not yet.  Although it can be setup manually if you have a bit of experience.  Denyhosts will look through your logs for these failed logins and add an entry for the attacker to /etc/hosts.deny blocking further attempts.

      There is a plugin for denyhosts called report-hack-isp that will automatically send a report with log exceprts to the owner of the IP address.  I receive quite a few responses back from the ISP's letting me know they resolved the infected computer.

      These links might be useful
      http://denyhosts.sourceforge.net/
      http://hubpages.com/hub/How-to-prevent-SSH-brute-force-attacks-using-DenyHosts
      https://github.com/nazar/report-hack-isp

      Check out my pfSense guides

      1 Reply Last reply Reply Quote 0
      • jimpJ Offline
        jimp Rebel Alliance Developer Netgate
        last edited by

        And the best option: Don't expose your ssh port to the world.

        Both 1 and 2 of skear's suggestions are good, but if your ssh port isn't open to the world, then you don't need other protections (but they don't hurt)

        On 2.0 sshlockout will block hosts that have repeated failed login attempts, no need for something extra like denyhosts.

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • N Offline
          novex
          last edited by

          :D Thanks Guys. Pfsense forum is great. i will only open 22 while i need it via webgui by public ip. Is it safer?

          1 Reply Last reply Reply Quote 0
          • B Offline
            Bai Shen
            last edited by

            @skear:

            I get tons of SSH hack attempts on my pfSense box and my linux server as well.  Most of the attacks come from zombie computers that are part of a botnet. There are a few things you can do to prevent them.

            1. Change the default ssh port - this will confuse most of the bots that look on port 22
            2. Setup key based authentication - this may not be feasible

            I find it to be much more fun to blacklist the attackers and report them to their ISP.

            If you want to go this route you can install Denyhosts, pfSense 1.2.3 has a package for it, 2.0 does not yet.  Although it can be setup manually if you have a bit of experience.  Denyhosts will look through your logs for these failed logins and add an entry for the attacker to /etc/hosts.deny blocking further attempts.

            There is a plugin for denyhosts called report-hack-isp that will automatically send a report with log exceprts to the owner of the IP address.  I receive quite a few responses back from the ISP's letting me know they resolved the infected computer.

            These links might be useful
            http://denyhosts.sourceforge.net/
            http://hubpages.com/hub/How-to-prevent-SSH-brute-force-attacks-using-DenyHosts
            https://github.com/nazar/report-hack-isp

            Interesting.  I've been using Snort to block attacks on my system.  I'll have to check out denyhosts.

            1 Reply Last reply Reply Quote 0
            • D Offline
              decibel83
              last edited by

              @novex:

              :D Thanks Guys. Pfsense forum is great. i will only open 22 while i need it via webgui by public ip. Is it safer?

              No, because if you cannot access to the web interface you will not be able to open the SSH port.
              Use a non default port for SSH, for example 8022!

              1 Reply Last reply Reply Quote 0
              • ? This user is from outside of this forum
                Guest
                last edited by

                Non default ports do not add security.  Do not expose SSH, if you must, limit the IP addresses which can access it and use key based authentication instead of password based authentication.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  danswartz
                  last edited by

                  Of course a non-standard port adds security.  How much is a debatable question, but I know from my own experience (and others) that we see far fewer attempts on non-standard ports than the standard port 22.

                  1 Reply Last reply Reply Quote 0
                  • Cry HavokC Offline
                    Cry Havok
                    last edited by

                    It adds obscurity, not security. That it stops the automated tools is certainly convenient though ;)

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      danswartz
                      last edited by

                      Well, now we're quibbling about the definition of security :)  I don't see this any different from having a harder to guess password - something everyone says "adds security".

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        tommyboy180
                        last edited by

                        I always use certificate based authentication on my ssh servers. I've never had to worry about a brute-force attack as a result.

                        -Tom Schaefer
                        SuperMicro 1U 2X Intel pro/1000 Dual Core Intel 2.2 Ghz - 2 Gig RAM

                        Please support pfBlocker | File Browser | Strikeback

                        1 Reply Last reply Reply Quote 0
                        • ? This user is from outside of this forum
                          Guest
                          last edited by

                          @danswartz:

                          Of course a non-standard port adds security.  How much is a debatable question, but I know from my own experience (and others) that we see far fewer attempts on non-standard ports than the standard port 22.

                          You're talking about security theater instead of security.  Having SSH on a non-standard port doesn't protect against service scanning, it just limits the number of robot-scanners trying to guess bad passwords.  If you are running a vulnerable SSHd, or you have bad passwords in place, running SSH on a non-standard port isn't going to protect you.

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            danswartz
                            last edited by

                            I think we have to agree to disagree here.  As far as weak passwords or exploitable sshd, nice strawman - I never said otherwise.  Again, if you have to try 20000 different ports * N different passwords, this is several orders of magnitude more difficult than hitting one well-known port.  By your logic, having a longer password with mixed case, etc, is just security theater?  If not, please explain more clearly why one is good and the other theater?

                            1 Reply Last reply Reply Quote 0
                            • Cry HavokC Offline
                              Cry Havok
                              last edited by

                              In real world terms:

                              • Moving your SSH port is like moving where the lock on the door is - it'll stop dumb automated attacks but nothing more

                              • Picking a strong password is like picking a strong lock - it makes it harder for every attacker

                              That's not to say that there isn't a slight gain from moving the port (I do it myself to cut down the noise in my logs), but it isn't really security in any meaningful sense.

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                danswartz
                                last edited by

                                Well, all I can say is if it only really helps against dumb automated scanners, that is the great preponderance of threats to ssh (I say this not just from personal experience, but from a wide range of people I've talked to, who monitor any attempts to hack their systems.)

                                1 Reply Last reply Reply Quote 0
                                • ? This user is from outside of this forum
                                  Guest
                                  last edited by

                                  Which is the point of our argument.  Automated scanners trying to guess obvious passwords are already defeated either by using good password security, ACLs or key based authentication.  Changing the default port adds no additional security.

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    danswartz
                                    last edited by

                                    Okay, I see your point.  I was looking at it from the PoV of someone's home network trying to figure out how to reduce threats, but yeah, you have a point.

                                    1 Reply Last reply Reply Quote 0
                                    • jimpJ Offline
                                      jimp Rebel Alliance Developer Netgate
                                      last edited by

                                      Changing to an alternate port does help cut down on log spam though, and if your logs are more relevant it's easier to spot a potential security issue or targeted breach when you don't have to sort through a bazillion automated attacks.

                                      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                      Need help fast? Netgate Global Support!

                                      Do not Chat/PM for help!

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post
                                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.