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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Port knocking hides SSH from ordinary port scans by keeping the SSH firewall rule closed until an administrator sends a prearranged sequence of packets. A daemon such as knockd listens for that sequence without opening the knock ports as services, then adds a temporary firewall rule for the sender’s IP address. The method can reduce unsolicited exposure, but it does not replace SSH keys, patching, least privilege, logging, or a recovery path.

What port knocking changes

With a normal Internet-facing SSH host, scanners can immediately see whether TCP port 22 responds. Port knocking changes the initial state: the firewall denies SSH, while knockd watches the network interface for packets aimed at a sequence of otherwise unused TCP or UDP ports. Because the daemon observes packets at link layer, those ports do not need listening applications.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. The firewall starts with SSH denied.
  2. The client sends the configured ports in the required order and protocol.
  3. knockd accepts the sequence only if it arrives before seq_timeout expires.
  4. The daemon runs a command that adds an SSH allow rule, normally restricted to the knocker’s source address through %IP%.
  5. A reverse sequence or a timed stop command removes that rule.

The Debian knockd(1) manual describes the purpose succinctly: “This can be used to open up holes in a firewall for quick access.” The hole is temporary only if your configuration includes a reliable close action.

Decide whether port knocking fits your threat model

Port knocking is an exposure-reduction control, not an authentication system. A fixed sequence is a shared secret sent as observable traffic. Anyone who captures it can replay it until you change the sequence. An attacker who can intercept or manipulate traffic may also interfere with the knock or the resulting connection. Ubuntu security guidance therefore treats knocking as an additional control and warns that it remains vulnerable to man-in-the-middle attacks.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
  • It helps against: routine automated scans and opportunistic connection attempts that never know the sequence.
  • It does not provide: cryptographic identity, confidentiality, protection from a compromised client, or a guarantee that SSH is unreachable to a determined observer.
  • It can hurt availability: a daemon, firewall, interface, or sequence-file error can lock out every administrator.

Before enabling a deny rule, retain console, out-of-band management, or a separate VPN recovery path. Test that path while you can still log in; do not make port knocking your only way back into a remote machine.

Requirements and a safe starting plan

  • A Linux host with a firewall you control and a public or otherwise reachable network interface.
  • The knockd package (the examples follow the Debian 0.7 manual; package names and service defaults can vary by distribution).
  • An SSH server already configured with key authentication and current security updates.
  • Administrative access through an existing SSH session plus a tested console, out-of-band, or VPN fallback.
  • The exact interface name that receives the knock packets. The manual’s default is eth0, but modern systems commonly use names such as ens3 or enp1s0.

Record your current firewall rules before changing them. On an iptables-based host, save a copy with your distribution’s firewall-management tool or at least capture iptables -S and iptables -L -n -v. Existing rule order matters: an earlier terminal DROP can prevent a later dynamic ACCEPT from ever matching.

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

Install knockd and identify the interface

On Debian or Ubuntu, install the package from the distribution repository in an already authenticated administrative session:

sudo apt update
sudo apt install knockd

Do not assume that installing the package enables packet listening. Inspect the service and its distribution defaults:

systemctl status knockd
ip -br link
ip -br addr

Use the interface carrying your server’s reachable address. Set it explicitly in the configuration instead of relying on the historical eth0 default, especially on hosts with multiple interfaces. Package versions may place the enable switch in a file such as /etc/default/knockd; follow the comments shipped with your package rather than copying a setting from another release.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Build the firewall state before opening SSH dynamically

The dynamic command must insert an allow rule ahead of any blanket SSH drop. The Debian manual’s example appends an ACCEPT rule and deletes the identical rule later:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[options]
logfile = /var/log/knockd.log
[openSSH]
sequence    = 7000,8000,9000
seq_timeout = 10
tcpflags    = syn
command     = /usr/sbin/iptables -A INPUT -s %IP% --dport 22 -j ACCEPT
[closeSSH]
sequence    = 9000,8000,7000
seq_timeout = 10
tcpflags    = syn
command     = /usr/sbin/iptables -D INPUT -s %IP% --dport 22 -j ACCEPT

This is documented syntax, not a universal firewall policy. If your INPUT chain ends with a DROP, use an insertion position that precedes that DROP (for example, an equivalent -I INPUT 1 command) and use the matching rule for deletion. Preserve established and related traffic, loopback, and any management exceptions required by your host. Apply equivalent policy to IPv6 if SSH is reachable over IPv6; the cited example is iptables-oriented and does not establish nftables or IPv6 behavior.

Keep port 22 closed to everyone by default. Do not create a permanent global ACCEPT merely to make testing easier. A useful test is to verify from a second network that a direct SSH attempt is refused or times out before you send a knock.

Configure the knock sequence

Create the configuration file used by your package (commonly /etc/knockd.conf) with an explicit interface and tightly scoped rules. Option names are case-insensitive in many releases, but retain the spelling shown by your installed manual.

[options]
Interface = ens3
LogFile = /var/log/knockd.log

[openSSH]
Sequence = 7000,8000,9000
Seq_Timeout = 10
TCPFlags = syn
Command = /usr/sbin/iptables -I INPUT 1 -p tcp -s %IP% --dport 22 -j ACCEPT

[closeSSH]
Sequence = 9000,8000,7000
Seq_Timeout = 10
TCPFlags = syn
Command = /usr/sbin/iptables -D INPUT -p tcp -s %IP% --dport 22 -j ACCEPT

The three ports and ten-second timeout are the manual’s example values, not magic numbers. Choose ports that do not collide with services or monitoring rules on your host, and keep the timeout short enough that a partial sequence expires quickly. Matching the TCP syn flag prevents unrelated traffic from being counted as a knock; use the protocol and flag behavior documented for your installed version.

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.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

%IP% is important: it limits the temporary SSH rule to the address that completed the sequence. Opening port 22 to all sources defeats the principal exposure benefit. If you use a command alias such as start_command or stop_command, verify the exact option names in the local knockd(1) manual; releases differ in whether they call the action command or use explicit start and stop fields.

Make the opening rule close automatically

A reverse sequence lets an administrator close access deliberately, but it is easy to forget. Prefer a timed start/stop pair when your version supports it: run the start command after a valid sequence, then run the stop command after a defined interval. Keep a reverse close sequence as an emergency operator action.

When a close action deletes a rule, its match must be byte-for-byte equivalent to the rule that was inserted: interface/chain, protocol, source address, destination port, and target. If those details differ, the delete command can fail while the SSH hole remains open. Check the live rules after both operations rather than trusting a successful process exit alone.

Use one-time sequences when replay matters

The Debian manual supports One_Time_Sequences. After a sequence is accepted, it is invalidated and replaced by the next sequence in the configured file; the manual states: “After each successful knock, the used sequence will be invalidated and the next sequence from the sequence file has to be used for a successful knock.” This improves resistance to capture-and-replay attacks, but it creates state that must be backed up and replenished.

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

Enable this mode only after you understand the sequence-file format and permissions documented by your installed package. Keep the file readable and writable only by the daemon’s required account, protect a spare copy offline, and document how to load a replacement sequence through console access. A lost or exhausted file can lock out every administrator even when the firewall and SSH daemon are healthy.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Enable the daemon and verify its logs

  1. Validate the file for syntax errors using the checking or foreground option documented by your package, if available.
  2. Enable the service at boot and start it: sudo systemctl enable --now knockd.
  3. Confirm the process is listening on the intended interface with systemctl status knockd and your system log or the configured logfile.
  4. From a separate network, confirm that direct SSH is blocked.
  5. Send one complete sequence, then inspect the firewall immediately for an ACCEPT rule containing your source address.
  6. Connect with SSH from that same source address, close the rule with the reverse sequence, and verify that the rule disappears.

If your distribution uses a different init system, service unit, logfile location, or firewall manager, use its shipped defaults. The Debian manual and package behavior are the reference for the syntax above; they do not guarantee identical paths on every Linux release.

Client workflow

The companion knock utility sends the ports in order. A typical session is:

knock -v server.example 7000 8000 9000
ssh admin@server.example
knock -v server.example 9000 8000 7000

Use the protocol expected by the server configuration. The manual notes that simple TCP knocks can also be generated with tools such as telnet or netcat, but those alternatives make it easier to send the wrong flags or protocol. Wait briefly for the firewall rule to be installed before starting SSH, and ensure both commands use the same public source address. If your client changes networks between the knock and the SSH connection, %IP% will not match and the connection remains blocked.

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

Test the packet path, rule ordering, and timeout

Confirm packets reach the selected interface

Run a packet capture during a test, restricted to the chosen ports and interface, and verify that packets arrive in the expected order. A capture that shows nothing usually indicates the wrong interface, an upstream firewall, or a client using UDP when the server expects TCP (or the reverse).

Confirm the sequence window

Deliberately pause longer than Seq_Timeout between two knocks. The partial sequence should expire and must not open SSH. Then send the complete sequence inside the window. This proves that the timeout is active rather than merely documented.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Confirm rule precedence

Inspect counters and order with iptables -L INPUT -n -v --line-numbers. The temporary source-specific ACCEPT must be evaluated before a general SSH DROP. If it is below that DROP, change the command to insert the rule earlier and retest the deletion command.

Confirm automatic closure

After the timed interval or reverse sequence, list the rules again. A disappearing rule is the evidence that closure works; a log message alone does not prove that the firewall state changed.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and recovery

The knock is logged but SSH remains blocked

  • Check that the source address in the dynamic rule is the address the server actually sees, especially behind NAT.
  • Check rule order: a preceding DROP, another firewall framework, or a cloud security group can override iptables.
  • Check that the SSH daemon listens on the port and address you are testing; the example assumes TCP 22.

No knock appears in the log

  • Verify the configured interface and its routing address.
  • Verify TCP versus UDP and the required TCP flags.
  • Check upstream firewalls and network ACLs that may discard the knock ports.

The rule will not close

  • Compare the delete command with the inserted rule, including protocol and source match.
  • Look for duplicate rules created by repeated successful knocks; remove only the intended source-specific entries through console access.
  • If a timed stop action failed, use the reverse sequence or an out-of-band firewall session immediately.

Administrators are locked out

Use the retained console, out-of-band channel, or VPN to stop the daemon and restore the previously saved firewall rules. Do not repeatedly guess sequences over the Internet; that can worsen a lockout and leave unclear firewall state. After recovery, test from the actual administrative network and add monitoring for daemon and rule-change failures.

Security controls that still matter

  • Use SSH public-key authentication and disable password authentication where your access policy permits.
  • Patch the operating system, SSH server, kernel, and firewall components.
  • Run administrative accounts with least privilege and require elevation for privileged actions.
  • Log SSH authentication and firewall changes, and alert on unexpected rule additions.
  • Restrict the temporary rule to the source IP and expose it only for the shortest practical interval.
  • Keep a tested recovery channel independent of the knock daemon.

Knocking can hide SSH from ordinary scanners, but it does not encrypt the knock sequence or authenticate the sender cryptographically. SSH’s own encryption and key verification remain the primary defense for the session itself.

Fixed sequences, one-time sequences, VPNs, and single-packet authentication

Design Visibility to unsolicited scans Replay resistance Operational complexity Control-channel authentication Recovery considerations
Fixed knockd sequence SSH can remain absent from ordinary scans until the sequence succeeds. Weak: an observed sequence can be replayed. Lowest; a small daemon configuration and firewall commands. None beyond possession of the sequence. Simple to reset, but a daemon or rule error can lock out administrators.
One-time knockd sequences Same scan-hiding behavior. Stronger against replay because accepted sequences are invalidated. Higher; sequence-file state, permissions, backup, and replenishment are required. Still not cryptographic identity. Protect against exhausted, lost, or desynchronized sequence files.
VPN-gated SSH SSH can be limited to the VPN address space. Depends on the VPN’s keys and configuration. Higher; separate service, client setup, routing, and key management. Can provide cryptographic peer authentication. Maintain an independent administrative path and VPN recovery procedure.
Single-packet-authentication design SSH remains closed until an authenticated packet is accepted. Depends on its cryptographic construction and key handling. Higher than a fixed sequence and requires separate deployment research. Designed to authenticate the control packet cryptographically. Document key rotation and a console fallback before enforcement.

The table compares design properties, not a benchmark. Choose a fixed sequence when simplicity and scan reduction are the goal; choose one-time sequences when replay is a material concern and you can operate sequence state; choose a VPN or authenticated single-packet design when you need a cryptographically authenticated control channel and can support its additional infrastructure.

IPv6, nftables, and cloud firewalls

The documented commands use IPv4 iptables. If the host has an AAAA record or an IPv6 address, test IPv6 separately and create equivalent controls with the firewall framework actually enforcing that traffic. Do not assume that an IPv4 rule, a knock observed on one interface, or an iptables command controls IPv6 packets. Likewise, systems managed by nftables, firewalld, UFW, or a cloud security group may translate or override iptables changes. Verify the effective ruleset and document which component owns it before putting a temporary command in production.

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

Operational checklist

  • Identify and explicitly configure the receiving interface.
  • Save the existing firewall rules and confirm a recovery channel.
  • Keep SSH denied by default and place the dynamic ACCEPT ahead of the terminal DROP.
  • Use a short sequence timeout and match the intended protocol and TCP flags.
  • Scope the temporary rule to %IP%; never open port 22 globally.
  • Automate closure with a timed stop action and retain a reverse close sequence.
  • Consider one-time sequences only with a documented, backed-up sequence-file process.
  • Do not enable DNS lookup casually; the Debian manual warns that resolving addresses can reveal the first port of a sequence and make a supposedly stealthy host identifiable.
  • Test direct blocking, successful opening, SSH access, timeout expiry, and closure over both IPv4 and IPv6 where applicable.
  • Monitor daemon health, firewall-rule changes, and SSH logs after deployment.

Bottom line

Port knocking is a practical way to keep an SSH daemon out of routine scans: deny SSH, listen for an ordered packet sequence, insert a source-specific rule, and remove it automatically. Treat the sequence as a convenience secret rather than authentication, use one-time sequences or a cryptographically authenticated alternative when replay matters, and never deploy the rule without a tested recovery path.

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.