HOWTO: Restrict ssh access by IP Address and/or username (2024)

Opening SSH to the outside world is a security risk. Here is how to restrict SSH access to certain IP addresses on a machine.

  1. Edit the /etc/hosts.allow file to include these lines, assuming your machine is on the 192.168.2.x nonrouting IP block, and you want to enable an external address of 217.40.111.121 IP block: Remember to add the period on the end of each incomplete IP number. If you have another complete IP address or range, add a space and that range on the end.
    sshd,sshdfwd-X11: 192.168.2. 217.40.111.121
  2. Edit your /etc/hosts.deny file to include this line:
    sshd,sshdfwd-X11:ALL 
  3. These lines refuse SSH connections from anyone not in the IP address blocks listed.

Additionally you can restrict SSH access by username.

  1. Edit the /etc/ssh/sshd_config file and add the following lines
    PermitRootLogin no
    AllowUsers user1 user2 user3 etc
    PasswordAuthentication yes

Now restart the ssh daemon for these changes to take effect

service sshd restart
HOWTO: Restrict ssh access by IP Address and/or username (2024)
Top Articles
4 Steps To Easy Student Loan Repayment
Questions Mortgage Lenders Can't Ask
Barstool Sports Gif
Cappacuolo Pronunciation
Star Sessions Imx
Best Big Jumpshot 2K23
Chicago Neighborhoods: Lincoln Square & Ravenswood - Chicago Moms
Slay The Spire Red Mask
Fallout 4 Pipboy Upgrades
LA Times Studios Partners With ABC News on Randall Emmett Doc Amid #Scandoval Controversy
R Tiktoksweets
ATV Blue Book - Values & Used Prices
24 Hour Walmart Detroit Mi
iLuv Aud Click: Tragbarer Wi-Fi-Lautsprecher für Amazons Alexa - Portable Echo Alternative
Louisiana Sportsman Classifieds Guns
Craiglist Kpr
Clear Fork Progress Book
How do I get into solitude sewers Restoring Order? - Gamers Wiki
Milspec Mojo Bio
Roof Top Snipers Unblocked
Aspen Mobile Login Help
Hennens Chattanooga Dress Code
A Biomass Pyramid Of An Ecosystem Is Shown.Tertiary ConsumersSecondary ConsumersPrimary ConsumersProducersWhich
Craigslist Northfield Vt
Menus - Sea Level Oyster Bar - NBPT
Defending The Broken Isles
Hellraiser 3 Parents Guide
Finding Safety Data Sheets
Dove Cremation Services Topeka Ks
Water Temperature Robert Moses
Fuse Box Diagram Honda Accord (2013-2017)
Busch Gardens Wait Times
Stubhub Elton John Dodger Stadium
Citibank Branch Locations In Orlando Florida
Metro By T Mobile Sign In
Baldur's Gate 3 Dislocated Shoulder
Kstate Qualtrics
Craigslist Org Sf
Pillowtalk Podcast Interview Turns Into 3Some
Craigs List Jonesboro Ar
Skyrim:Elder Knowledge - The Unofficial Elder Scrolls Pages (UESP)
Felix Mallard Lpsg
More News, Rumors and Opinions Tuesday PM 7-9-2024 — Dinar Recaps
Miami Vice turns 40: A look back at the iconic series
Emily Browning Fansite
Marcal Paper Products - Nassau Paper Company Ltd. -
Scythe Banned Combos
Ssc South Carolina
Tacos Diego Hugoton Ks
2294141287
Hampton Inn Corbin Ky Bed Bugs
Kindlerso
Latest Posts
Article information

Author: Gov. Deandrea McKenzie

Last Updated:

Views: 6382

Rating: 4.6 / 5 (66 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Gov. Deandrea McKenzie

Birthday: 2001-01-17

Address: Suite 769 2454 Marsha Coves, Debbieton, MS 95002

Phone: +813077629322

Job: Real-Estate Executive

Hobby: Archery, Metal detecting, Kitesurfing, Genealogy, Kitesurfing, Calligraphy, Roller skating

Introduction: My name is Gov. Deandrea McKenzie, I am a spotless, clean, glamorous, sparkling, adventurous, nice, brainy person who loves writing and wants to share my knowledge and understanding with you.