Linuxaria

Everything about Linux
  • Home
  • Article
    • News
  • Howto
  • Interview
  • Pills
  • Review
  • Information
    • Contribute
    • Contact me
    • Info
    • Privacy Policy
  • Links
    • GMStyle
    • Il Bloggatore
    • Linux
    • Linux Today
    • Linuxfeed
    • LinuxInsight
    • Lxer
    • ZioBudda

Sponsor

3 easy steps to strengthen your ssh server

 Howto  Add comments
Sep 282011
 

Back on ssh topic, i think this is third or perhaps the fourth article regarding ssh, one of my favorite tools on a Linux server, and that a lot of times is not used or configured properly. In this small guide i’ll show you some setup to make your ssh server a bit more safer from the most common attacks.

In particular i’ll show the configurations for openssh that is the most common and used ssh server in all Linux distributions but, as small suggestion, if you are using a VPS and you want to save some memory check also dropbear, it’s a valid alternative to openssh and it saves some space in your ram.




For Debian and Ubuntu (but also for other distributions) the configuration file it’s located at /etc/ssh/sshd_config and at the end of all changes you’ll need to restart ssh daemon.

1 – Disable root access

I’ve always thought that direct connection with root account it’s a bad habit, because

  • Attackers already know the username, so just need to discover the password
  • If the account it’s hacked your machine it’s FUBAR
  • If more than 1 people administers that machine it’s better to use sudo to track who does things.

So to disable direct root connection set this option:

PermitRootLogin no

2 – Enable only some users or groups

Probably on your machine only a few users must login via ssh, if they are just a few you can use the directive:

AllowUsers username

This option can be followed by a list of user name patterns, separated by spaces.If specified, login is allowed only for user names that match one of the patterns.`*’ and `?’ can be used as wildcards in the patterns. or if you want to manage the access via a group you can use another option:

AllowGroups groups

Like above this option can be followed by a list of group name patterns, separated by spaces.If specified, login is allowed only for users whose primary group or supplementary group list matches one of the patterns.`*’ and `?’ can be used as wildcards in the patterns

These 2 directives are really useful because you don’t have to worry anymore of the products that when installing set up a new account, maybe with a weak password.

3 – Change the standard port

Another safety rule is to change the default port, ie 22, since most of the automated tools perform Brute Force attacks or Dictionary Attacks right on this port.

It’ better to use a port above 1024, because the port scanners usually scans the first 1024 ports, so we’ll use the 2222.

So we change the directive substituting 2222 to 22

Port 2222

Now to connect to yourserver.com with your ssh client you have to specify the port, this is easily done adding the -p option to the openssh client:

ssh -p 2222 yourserver.com

Conclusions

And that’s all, as you can see these are really 3 easy steps, but they will make your server more secure from the most common attacks.

Popular Posts:

  • How to protect Apache with Fail2ban
  • Nightingale a Beautiful music player for Linux
  • Linux shell: Dfc – Check your disk space with style
  • Livarp – A lightweight Linux Distribution
  • How to convert YouTube Video to MP3 easily on GNU/Linux

Find me on Google+

flattr this!

 Posted by Riccardo at 23:25  Tagged with: dropbear, linux server, openssh, root account, root connection, server linux, ssh server, vps

  3 Responses to “3 easy steps to strengthen your ssh server”

  1. Ridgeland says:
    09/29/2011 at 12:58

    4th should be edit hosts.allow
    Do you really need to allow the whole planet to connect?
    On my Mom’s ssh server only hosts allowed are connections from my ISP (US – small phone cooperative). Even though her router only works with port 22 all attempts to connect but mine have seen “connnection refused”. Even if your ISP is a big US company this would drop all South America, Africa, Europe, Asia connection attempts.
    hosts.deny of course is ALL:ALL

    Reply
  2. LittleHead says:
    09/30/2011 at 00:05

    I suggest to disable password authentication and use only public keys auth so you don’t have to bother for weak passwords, brute force attacks or someone looking from your back.

    Reply
  3. DarwinSurvivor says:
    09/30/2011 at 01:22

    You forgot about using private-public keys and disabling password login. I’ve never heard a single report of anyone brute-forcing a public/private key, but passwords are brute-forced daily.

    Reply

 Leave a Reply Cancel reply

(required)

(required)

CAPTCHA Image
Refresh Image

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  Synchrorep: A simple way to synchronize folders   Introduction to Cgroups, the Linux Control Group
  • English
  • Italiano

Follow Me

RSS Twitter Facebook Google+

Sponsor

Popular posts

  • How to protect Apache with Fail2ban
  • Nightingale a Beautiful music player for Linux
  • Linux shell: Dfc – Check your disk space with style
  • Livarp – A lightweight Linux Distribution
  • How to convert YouTube Video to MP3 easily on GNU/Linux

Subscribe by Email

Subscribe to RSS» English by mail

Iscriviti agli RSS» Italiano via Email

Recent Comments

  • fra su Copy – Un nuovo servizio di disco su Cloud con applicazione per Linux
  • linuxari su Livarp – Una distribuzione Linux molto leggera
  • linuxari su Copy – Un nuovo servizio di disco su Cloud con applicazione per Linux
  • linuxari su Flareget un ottimo gestore di download per Linux
  • Deekshith su Copy – Un nuovo servizio di disco su Cloud con applicazione per Linux

RSS Hubpages feed

  • RamDisk on Linux : what it is and how to use it.
  • Is your Password safe ?
  • Introduction to AnoN-1mOS a new Linux Distribution
  • 5 Popular Paid Games for Linux
  • 6 Torrent clients for Linux
© 2013 Linuxaria All site content, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Suffusion theme by Sayontan Sinha