DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

How to Install DenyHosts to Block SSH Attacks on a Linux VPS

Install DenyHosts safely on a Linux VPS with SSH-only blocking, administrator whitelisting, threshold configuration, daemon verification, purge settings, and lockout recovery steps.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install DenyHosts by creating its configuration before startup, allowing your trusted administrator address, setting SSH-only blocking and sensible thresholds, then starting the daemon and checking its log. DenyHosts is a Python utility that watches SSH authentication failures and records offending hosts for denial, traditionally through /etc/hosts.deny. On packaged Debian systems, its configuration is commonly /etc/denyhosts.conf.

The order matters: if your current management address is not allowed before blocking begins, DenyHosts can lock you out. The procedure below covers a distribution package and a source installation, configuration, verification, purging stale entries, and recovery.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What DenyHosts does on a VPS

The maintained project describes DenyHosts as “a utility developed by Phil Schwartz and maintained by a number of developers which aims to thwart sshd (ssh server) brute force attacks.” It monitors SSH authentication failures, counts attempts by category, and adds offending addresses to a deny mechanism. The traditional enforcement path is /etc/hosts.deny, so the effective result depends on the SSH service and host-access mechanism on your distribution honoring that file.

DenyHosts is not an SSH replacement, credential manager, or complete firewall. It is a host-based reaction layer: an address accumulates failed attempts, crosses a configured threshold, and is denied. You still need strong credentials or keys, timely updates, least-privilege accounts, and a recovery path for legitimate administrators.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Requirements and decisions before installation

  • Root access: Source installation, configuration under /etc, log setup, and daemon startup require root or equivalent administrative privileges.
  • Python and the ipaddr module: The project requires ipaddr; many Linux and BSD repositories provide it. Install the package supplied by your distribution before running a source installation.
  • A confirmed management address: Identify every address you may use to administer the VPS, including a fixed office address, VPN egress address, jump host, or automation host. Dynamic addresses need a different operational plan because a future address can differ from the one you whitelist today.
  • An out-of-band recovery route: Keep your VPS provider’s console or another already-authorized session available while testing. Do not enable blocking for the first time with your only SSH session at risk.
  • A log location: Decide where DenyHosts will write its daemon log and verify that the service account can write there. The project commonly uses /var/log/denyhosts, but the configured path on your package or release is authoritative.

Install the distribution package

A distribution package is normally the simplest route because it supplies the executable, default paths, and often service integration. Use your Linux distribution’s package manager to install its DenyHosts package, then verify that the command and configuration path exist. Package names and service-unit names vary, so do not assume a universal systemd unit name.

  1. Install DenyHosts and the distribution package that provides the required ipaddr Python module, if they are separate packages.
  2. Confirm the executable is on the path with command -v denyhosts.
  3. Check the packaged command-line help with denyhosts --help. The Debian manpage documents --config, --daemon, --purge, and --migrate.
  4. Confirm that /etc/denyhosts.conf exists. If it does not, do not start the daemon yet; create the file as described in the configuration section.

Some releases include a systemd service unit. Because unit names and enablement policies differ by distribution, list the units supplied by your package and use the name actually installed rather than copying a command intended for another distribution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install from source when no suitable package is available

Use the source procedure when your distribution does not provide a usable package or when you need the maintained project’s release directly. Keep the release directory until you have copied the configuration and control files you need.

  1. Download and unpack the DenyHosts release on the VPS, then change into the unpacked directory.
  2. Install the required ipaddr module through your operating system’s repository or the Python environment appropriate to the release.
  3. As root, run the project’s installation command:
    python setup.py install
  4. Copy the sample configuration from the release into /etc/denyhosts.conf.
  5. Edit /etc/denyhosts.conf before starting anything. Set the log location, service scope, thresholds, allowed hosts, and purge policy you intend to use.
  6. Copy the release’s daemon-control distribution script into the location used by your system. Edit its DENYHOSTS_BIN, DENYHOSTS_LOCK, and DENYHOSTS_CFG paths so they match the installed executable, lock file, and /etc/denyhosts.conf.
  7. Make the control script executable by root, and test it only after the configuration and whitelist are complete.

The source release’s control script is a distribution template rather than a universal init-system contract. Check the paths in the script and adapt its invocation to the init system on your VPS.

Create and secure /etc/denyhosts.conf

The configuration file must exist before startup. Packaged Debian systems commonly use /etc/denyhosts.conf; a source install should copy the release’s sample file to that path unless you deliberately choose another path and pass it with --config.

Limit enforcement to SSH

Set:

BLOCK_SERVICE = sshd

This limits DenyHosts’ blocking decision to SSH. The sample also documents:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
BLOCK_SERVICE = ALL

ALL is available when every supported service should be blocked. It is a materially broader policy, so use sshd unless you have deliberately assessed the effect on other services.

Choose failure thresholds

The sample configuration supplies these defaults:

Setting Sample default What it counts
DENY_THRESHOLD_INVALID 5 Invalid-user authentication attempts
DENY_THRESHOLD_VALID 10 Failed attempts against a valid account
DENY_THRESHOLD_ROOT 1 Root-login attempts
DENY_THRESHOLD_RESTRICTED 1 Attempts involving a restricted user category

These are sample defaults, not universal requirements. Lower values react faster but increase the chance that a mistyped password or a shared NAT address is denied. Higher values tolerate more mistakes but leave an attacker more attempts. Set them with your account policy and the number of legitimate users behind each source address in mind.

Allow administrators before enabling blocking

Use DenyHosts’ allowed-hosts mechanism to whitelist every trusted administration address before the first daemon start. Keep the entries narrow: allow the exact address or hostname you control rather than a broad network unless you have a specific reason.

The sample sets:

ALLOWED_HOSTS_HOSTNAME_LOOKUP = NO

With hostname lookup disabled, entries are handled without reverse-DNS lookups. The configuration can perform hostname lookups for allowed entries when this option is enabled; doing so adds DNS dependency and should be intentional. After editing the allow list, verify the spelling and address from a second session or from your provider’s console.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Review log and state paths

Confirm the configured daemon log path, lock path, and any state files before startup. The project commonly recommends checking /var/log/denyhosts. Ensure the directory exists and permissions allow the daemon to write, while keeping the files readable only by administrators where they may contain account names or source addresses.

Start DenyHosts safely

Start only after the configuration file and administrator allow list are in place.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
  1. Keep your current SSH session open and establish a second session from an allowed address.
  2. Start the daemon with your distribution’s service integration, if one is installed, or with the project control script.
  3. The documented direct form is:
    python /usr/local/bin/denyhosts --config /etc/denyhosts.conf --daemon
    Use the actual executable path installed on your VPS if it differs.
  4. Check the daemon log immediately. Look for successful startup, the configuration path being read, the monitored SSH log, and the creation or update of deny state.
  5. Confirm that the process remains running and that the log timestamp advances when new SSH authentication events occur.

If your package supplies a systemd unit, inspect the installed unit name and status rather than assuming a fixed name. A release-history entry records a systemd service unit, but availability and naming remain distribution-specific.

Verify that blocking works without locking yourself out

Verification should prove observation and policy, not create a real attack. First, confirm that DenyHosts can read the SSH authentication log and write its own state. Then inspect the configured deny file or access-control output for an entry that was added by policy.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Read the DenyHosts log at the configured path and confirm that it reports monitoring activity.
  • Inspect /etc/hosts.deny if your installation uses the traditional hosts-access mechanism. Record the format of entries before making any manual change.
  • Check that your administrator address is present in the allowed-hosts configuration and absent from the deny list.
  • Use a disposable test account or a controlled test address only if you can recover through an alternate session. Do not deliberately fail authentication from your sole management address.
  • After testing, remove any test state through the documented purge or removal procedure and recheck the log.

DenyHosts does not provide a performance benchmark in the maintained project material. Treat it as a policy and log-monitoring control, and measure its operational effect on your own VPS if you need capacity data.

Set automatic expiration with purge options

Permanent denials become an operational problem when addresses are reassigned, users change networks, or a temporary attack ends. Set PURGE_DENY to a duration when you want timestamped deny entries to expire. The sample accepts values such as:

PURGE_DENY = 1w

or:

PURGE_DENY = 5d

Run the purge operation with the installed executable:

denyhosts --purge

If your package uses a wrapper or service command, use its documented equivalent. In daemon mode, DAEMON_PURGE = 1h controls how often the purge mechanism runs when purging is enabled. PURGE_THRESHOLD can limit how many times an address is purged before it remains denied; use it when repeat offenders should not cycle indefinitely between expiration and re-blocking.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Before purging, confirm the address and your access path. Purging a stale address is routine; purging the address you are currently using without an alternate session can turn a maintenance task into a lockout.

Remove a blocked administrator address

When your own address is denied, stop making repeated login attempts. Repeated failures can increase the recorded count and make recovery harder.

  1. Connect through an already-authorized SSH session or your VPS provider’s out-of-band console.
  2. Confirm the public address that is blocked and compare it with the address shown by your current connection. Do not remove an entry based only on a hostname that may resolve elsewhere.
  3. Add the trusted address to the allowed-hosts configuration before removing the deny entry.
  4. Use the documented DenyHosts purge/removal operation for the blocked-host state, or perform the distribution’s supported administrative edit if its documentation requires one.
  5. Restart or reload the daemon only as directed by your package or control script, then inspect the log for a clean recovery.
  6. Open a fresh SSH session from the allowed address before closing the console or your original session.

The DenyHosts FAQ describes purge behavior and blocked-host tracking. Preserve a copy of the relevant state before manual edits so you can identify whether the address is re-added by a still-active threshold or by another access-control tool.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failure modes and fixes

The daemon will not start because the configuration is missing

Create /etc/denyhosts.conf from the release sample, or pass the actual configuration path with --config. Check file ownership, syntax, and the log path before retrying.

Python reports a missing ipaddr module

Install the ipaddr module from your Linux or BSD repository, then rerun the source installation or start command in the same Python environment. Verify the module is visible to the interpreter used by the DenyHosts executable.

Authentication failures are not being counted

Check that DenyHosts is watching the SSH authentication log generated by your distribution, that the configured path is readable, and that the daemon log shows a live monitor. A custom SSH-log format may require the project’s configurable failed-entry regular expressions.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Your address was denied despite being trusted

Confirm that the address in the allowed-hosts mechanism exactly matches the address reaching the VPS. Check whether you are connecting through a VPN, NAT gateway, jump host, or changing IPv6 address. Verify the hostname-lookup setting and inspect both allowed and denied state before restarting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Other services are being blocked unexpectedly

Review BLOCK_SERVICE. Use sshd for SSH-only enforcement; ALL intentionally broadens the policy.

Old entries never disappear

Confirm that PURGE_DENY is set to a valid duration, run denyhosts --purge, and check whether PURGE_THRESHOLD is retaining repeat offenders. In daemon mode, verify that DAEMON_PURGE is enabled at the interval you expect.

A systemd command from another guide does not work

List the service units installed by your package and use the unit name supplied for your distribution. DenyHosts release history includes systemd support, but unit naming and packaging are not universal.

DenyHosts compared with firewall-based SSH defenses

DenyHosts and a firewall-based blocker solve a similar symptom through different enforcement layers. Choose using the following axes rather than an unsupported speed claim:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Decision axis DenyHosts Firewall-based defense
Log source and parser Parses SSH authentication failures and applies threshold categories. May parse the same logs, but parser coverage depends on the specific firewall tool.
Enforcement mechanism Traditionally host access through /etc/hosts.deny; optional integrations are available. Creates network-layer rules that can drop or reject traffic before SSH handles it.
Whitelist and recovery Allowed-hosts settings, purge controls, and blocked-host tracking are built into its configuration and maintenance flow. Recovery depends on the firewall’s rule and persistence tools plus an out-of-band route.
Threshold and expiration Separate invalid, valid, root, and restricted-user thresholds; PURGE_DENY and PURGE_THRESHOLD govern expiration. Threshold and ban duration depend on the selected firewall integration.
Services beyond SSH BLOCK_SERVICE = sshd narrows scope, while ALL broadens it. Usually controlled by firewall ports, chains, or service-specific rules.
Maintenance Requires a compatible Python runtime, ipaddr, package or source maintenance, and log review. Requires maintaining the firewall tool and ensuring rules survive reloads or reboots.

The available project material does not establish a current performance comparison. Select the layer your team can safely whitelist, monitor, and recover.

Optional integrations and synchronization

The configuration includes optional PF-table and iptables-related integrations, plugin hooks, custom failed-entry regular expressions, email reporting, and synchronization settings. Enable an integration only after confirming that it matches the firewall and init system on your VPS; a syntactically valid option can still conflict with local rule management.

Release notes describe synchronization-server support and invalid-account detection. Synchronization upload and download are opt-in. Evaluate privacy, data-sharing, retention, and operational fit before enabling synchronization, and document how a remotely learned denial can be reversed.

Operational checklist

  • Before start: /etc/denyhosts.conf exists, the ipaddr module is available, and the log path is writable.
  • Access safety: Every trusted administrator address is allowed, and a second session or console is available.
  • Scope: BLOCK_SERVICE = sshd is set unless broader service blocking is deliberate.
  • Policy: Thresholds are reviewed rather than copied blindly from the sample.
  • Verification: The daemon log shows startup and ongoing SSH-log monitoring; deny state changes are visible.
  • Maintenance: PURGE_DENY, DAEMON_PURGE, and, where needed, PURGE_THRESHOLD have an explicit policy.
  • Recovery: You know how to reach the VPS without the blocked address and how to remove a confirmed stale entry.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.