Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm very new to network administration, so please regard that I'm not that experienced yet.

I have a Ubuntu root server with plesk panel.

Yesterday my friends and I noticed that the quality of speech on our TS3 got very bad. I sent some pings to the server and there was a very high packet loss. After that i googled a bit and found out that there is a auth.log. I downloaded it and scrolled a bit around, then I found this:

May 13 10:01:27 rs204941 sshd[9351]: input_userauth_request: invalid user student [preauth]
May 13 10:01:27 rs204941 sshd[9351]: pam_unix(sshd:auth): check pass; user unknown
May 13 10:01:27 rs204941 sshd[9351]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost= 
May 13 10:01:29 rs204941 sshd[9351]: Failed password for invalid user student from port 39806 ssh2
May 13 10:01:29 rs204941 sshd[9351]: Received disconnect from 11: Bye Bye [preauth]
May 13 10:01:31 rs204941 sshd[9353]: Invalid user student from

It seems like someone tried to log in over SSH many times. I scrolled a bit around, and saw, that this someone tries to use many different usernames: student, tech, psi, news,...

Hundreds of these logins were displayed in the file.

I looked up the traffic statistics at the website of my datacenter. It was only at 17MB per hour. I have a 100Mbit Backbone, so the data transfer itself seems not to be the problem.

At the moment i cannot get acces to the server in any way.

My Question is: how can i get acces again, how can i surpress this attack and prevent following attacks?

share|improve this question
Still learning my stuff in this department.... But wouldn't this be a good use for port knocking? – mjrider May 13 '14 at 11:54
up vote 20 down vote accepted

How to gain access?

It's not clear why you can't access your account.

If your machine is under attack or high load, you should talk to your provider about restricting access (IP Restrictions) or taking the server offline (disconnect from the Internet).

You might also require out of band access which your provider may be able to help with.

If somebody has compromised your server you may need to restore from backups or use a recovery image.

How to prevent attacks on your server, in particular SSH

best way to prevent brute force logons?

Don't let them get to your machine in the first place! There are plenty of ways to stop brute force attempts before they get to your host, or even at the SSH level.

Having said that, protecting your Operating System with something like fail2ban is a great idea.

Fail2ban is similar to DenyHosts ... but unlike DenyHosts which focuses on SSH, fail2ban can be configured to monitor any service that writes login attempts to a log file, and instead of using /etc/hosts.deny only to block IP addresses/hosts, fail2ban can use Netfilter/iptables and TCP Wrappers /etc/hosts.deny.

There are a number of important security techniques you should consider to help prevent brute force logins:


  • Don't allow root to login
  • Don't allow ssh passwords (use private key authentication)
  • Don't listen on every interface
  • Create a network interface for SSH (e.g eth1), which is different to the interface you serve requests from (e.g eth0)
  • Don't use common usernames
  • Use an allow list, and only allow users that require SSH Access
  • If you require Internet Access...Restrict Access to a finite set of IPs. One static IP is ideal, however locking it down to x.x.0.0/16 is better than
  • If possible find a way to connect without Internet Access, that way you can deny all internet traffic for SSH (e.g with AWS you can get a direct connection that bypasses the Internet, it's called Direct Connect)
  • Use software like fail2ban to catch any brute force attacks
  • Make sure OS is always up to date, in particular security and ssh packages


  • Make sure your application is always up to date, in particular security packages
  • Lock down your application 'admin' pages. Many of the advice above applies to the admin area of your application too.
  • Password Protect your admin area, something like htpasswd for web console will project any underlying application vulnerabilities and create an extra barrier to entry
  • Lock down file permissions. 'Upload folders' are notorious for being entry points of all sorts of nasty stuff.
  • Consider putting your application behind a private network, and only exposing your front-end load balancer and a jumpbox (this is a typical setup in AWS using VPCs)
share|improve this answer
I have installed Fail2ban via It seems to be very powerfull and user-friendly(Mail notifications,...) – boujama May 13 '14 at 12:05
I got a message from my datacenter: There was a floodattack(what is this?) and this made the connection very bad for many servers. It was not a attack on my server especially. – boujama May 13 '14 at 12:11
Interesting. So it seems that my datacenter was the target of the attack. But to know I got bruteforced besides this, is very good too. And Fail2ban is really a good tool. I will read about Iptables and SSH Config the next days and try to make it much more safe. – boujama May 13 '14 at 14:07
Configure openssh to listen to a port other than 22, and configure iptables to drop anything coming to port 22. If you don't expect to ssh in from any other country than your homeland, create a block list at and use it with iptables. – ThoriumBR Apr 10 '15 at 17:58

how can i surpress this attack and prevent following attacks

Usually i change the default ssh port from 22 to another like 1122. This prevent many automatic attacks from bot, but a simple port scan can detect it. Anyway:

vi /etc/ssh/sshd_config

and edit Port 22 to Port 1122, but this is not enough.

Automatic IPTables rules on bruteforce

i use log2iptables instead Fail2ban, because is a simple Bash script that parse any logfile with a regular expression and execute iptables. For example when 5 matches occur, log2iptables drop the specific ip address. It's cool because use Telegram API and can send me a message on my phone when he find a problem :)

hope this will help!

share|improve this answer
I'm guessing from the correlation between the project URL and your SF handle, that you're involved with this project. Please see our guidelines on referencing your own products, in particular noting the requirement that "you must disclose your affiliation in your answers". – MadHatter Nov 19 '15 at 8:49

This is my alternative solution for SSH attacks. The idea is keep closing SSH daemon if not use. No open port no attack. You can try it. It is open source

share|improve this answer
Welcome to Server Fault! Your answer suggests a workable solution to the question is available via another website. The Stack Exchange family of Q&A websites generally frowns on this type of answer because other websites may move, get deleted, or changed. Please read How do I write a good answer? and consider revising your answer to include the steps required to resolve the issue. And don't forget to take the site tour. – Paul Apr 10 '15 at 16:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.