Demons Seeking Dæmons—A Practical Approach to Hardening Your OpenSSH Configuration
Chances are, if you are the owner or administrator of a Linux machine, you access it remotely from time to time, if not constantly. Be it a workstation at home, a co-located server or a hobby machine, if you are accessing Linux remotely, there is a good chance that you are using the OpenSSH server on the remote machine with some type of SSH client locally. (If you are not, you probably should be.) Although it is true that the OpenSSH server and clients do a tremendous job at encrypting the traffic that passes between systems, it also is true that any dæmon listening for connections is a door handle waiting to be turned by the black hats, the evildoers or the crackers. The less-desirable folks in these situations are, as the title states, demons seeking dæmons, a person or group of people that usually are up to no good seeking listening dæmons that, depending on the configuration of the machine, may or may not be secure. Hackers can be defined as people who have relatively benign motives for breaking into a system. Crackers often are thought of as hackers with malicious intent. Neither the former nor latter is welcome on my machines. In this article, I expand on the basic OpenSSH configuration and cover ways to improve the security of the SSH dæmon to offer more protection to your machines. If you have a machine that suffers a compromise, your machine may be helping to spread your unpleasantness to others as well. The Internet is one of the largest insecure data routes on the face of our planet.
OpenSSH provides the means for secure communication over insecure channels. The file sshd_config is the ruling party in the game of secure shell configuration. The sshd_config file consists of multiple options that can be changed to help improve the security of the listening dæmon. Although it may seem that because it is a remote access tool it should be secure right out of the box, this is hardly the case. For the most part, a default installation of the OpenSSH server will provide you with a relatively secure default configuration but one that can be improved substantially by the machine's administrator.
When planning for remote access initially, it is suggested that you consider three major things for the access of your machines:
Who will be allowed access to the machines?
How will this access be provided?
From where will this access be allowed?
We are going to assume that we will be using the OpenSSH server to provide remote access. This leaves us with the questions of who will be allowed remote access and from where they will be allowed. For some, this may be simple; perhaps the machine supports only a single user and remote access is carried out from a single domain. For others, this can be quite a challenge when multiple users that travel frequently are the machine's users.
The first and foremost person on a Linux machine is the root user. This is universally known, and it also should be universally known that if you need to have remote root access to a machine, there are many better ways to access as root than simply using SSH and logging in as root. If you think about the fundamentals of a brute-force attack attempt, it is obvious that the most relevant account that will be attacked is the root account. One need not guess whether the account is present; it is there. The sshd_config file lets us specify that root is not allowed to log in remotely at all through the PermitRootLogin directive.
I fully believe that the saying “an ounce of prevention equals a pound of cure” is highly accurate when dealing with remote-use accounts. Two options allowed in the sshd_config file, UsersAllow and UsersDeny, are more than an ounce of prevention, and although it may be one extra step when adding an account, modifying the UsersAllow for each account added provides that pound of cure that you may (thankfully) never need to seek. To expand on the UsersAllow directive, you cannot specify only particular users, but you also can specify particular users at specific hosts. So, if in advance you know exactly who will need to log in and from where, the minimal time overhead associated with adding these directives to the sshd_config file provides the peace of mind for you to know you are allowing remote access for only specific accounts from specific machines. Valid users can be retrieved from the /etc/passwd file in standalone machines or from the corresponding files in NIS or LDAP environments. Listing 1 is an example of parsing the previous month's security files to verify which accounts have logged in successfully using SSH.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- RSS Feeds
- A Topic for Discussion - Open Source Feature-Richness?
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Readers' Choice Awards
- The Secret Password Is...
- All the articles you talked
1 hour 32 min ago - All the articles you talked
1 hour 35 min ago - All the articles you talked
1 hour 37 min ago - myip
6 hours 2 min ago - Keeping track of IP address
7 hours 53 min ago - Roll your own dynamic dns
13 hours 6 min ago - Please correct the URL for Salt Stack's web site
16 hours 17 min ago - Android is Linux -- why no better inter-operation
18 hours 33 min ago - Connecting Android device to desktop Linux via USB
19 hours 1 min ago - Find new cell phone and tablet pc
19 hours 59 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
ssh work
The new work about ssh server is to be access very carefully to get fixed.
ssh -p <alternate port>
"I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone."
-- Bjarne Stroustrup
Denyhosts
"DenyHosts is a python program that automatically blocks ssh attacks by adding entries to /etc/hosts.deny. DenyHosts will also inform Linux administrators about offending hosts, attacked users and suspicious logins." Very nifty when your machine is getting hammered with brute force attacks. You can find it here.