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
What Is a Smart Contract Audit?
The Best Place to Put Your Router
Urist Mcenforcer
Mcgeorge Academic Calendar
Avonlea Havanese
Craigslist Cars Augusta Ga
Craigslist Benton Harbor Michigan
More Apt To Complain Crossword
Fcs Teamehub
2021 Tesla Model 3 Standard Range Pl electric for sale - Portland, OR - craigslist
Audrey Boustani Age
Taylor Swift Seating Chart Nashville
Mission Impossible 7 Showtimes Near Regal Bridgeport Village
George The Animal Steele Gif
Nioh 2: Divine Gear [Hands-on Experience]
Non Sequitur
Otterbrook Goldens
Maplestar Kemono
Arre St Wv Srj
Sport-News heute – Schweiz & International | aktuell im Ticker
Palm Coast Permits Online
Spider-Man: Across The Spider-Verse Showtimes Near Marcus Bay Park Cinema
Prestige Home Designs By American Furniture Galleries
Uta Kinesiology Advising
Walgreens 8 Mile Dequindre
Times Narcos Lied To You About What Really Happened - Grunge
manhattan cars & trucks - by owner - craigslist
4.231 Rounded To The Nearest Hundred
The Goonies Showtimes Near Marcus Rosemount Cinema
031515 828
Planned re-opening of Interchange welcomed - but questions still remain
Mosley Lane Candles
Sam's Club Near Wisconsin Dells
3473372961
Learn4Good Job Posting
Sf Bay Area Craigslist Com
Opsahl Kostel Funeral Home & Crematory Yankton
Rvtrader Com Florida
Koninklijk Theater Tuschinski
Craigslist Lakeside Az
manhattan cars & trucks - by owner - craigslist
Tinfoil Unable To Start Software 2022
Southwest Airlines Departures Atlanta
Tacos Diego Hugoton Ks
A rough Sunday for some of the NFL's best teams in 2023 led to the three biggest upsets: Analysis
Marcel Boom X
Best Restaurant In Glendale Az
San Diego Padres Box Scores
Gear Bicycle Sales Butler Pa
2487872771
Provincial Freeman (Toronto and Chatham, ON: Mary Ann Shadd Cary (October 9, 1823 – June 5, 1893)), November 3, 1855, p. 1
Salem witch trials - Hysteria, Accusations, Executions
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.