Somebody get access to my server. Pls help me to understand how it happened

October 15, 2013 2.6k views
Hello. DigitalOcean support banned my account because my server was trying to get acces to another one. Here is log from target server: > Oct 8 17:09:51 c-3po sshd[31374]: Did not receive identification string from 82.196.2.248 > Oct 8 18:49:19 c-3po sshd[7318]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=82.196.2.248 user=root > Oct 8 18:49:21 c-3po sshd[7318]: Failed password for root from 82.196.2.248 port 36473 ssh2 > Oct 8 18:49:22 c-3po sshd[7322]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=82.196.2.248 user=root > Oct 8 18:49:24 c-3po sshd[7322]: Failed password for root from 82.196.2.248 port 36737 ssh2 > Oct 8 18:49:25 c-3po sshd[7324]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=82.196.2.248 user=root > Oct 8 18:49:27 c-3po sshd[7324]: Failed password for root from 82.196.2.248 port 36868 ssh2 > Oct 8 18:49:28 c-3po sshd[7326]: Invalid user abcs from 82.196.2.248 > Oct 8 18:49:28 c-3po sshd[7326]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=82.196.2.248 > Oct 8 18:49:30 c-3po sshd[7326]: Failed password for invalid user abcs from 82.196.2.248 port 37010 ssh2 > Oct 8 18:49:31 c-3po sshd[7328]: Invalid user admin from 82.196.2.248 > Oct 8 18:49:31 c-3po sshd[7328]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=82.196.2.248 > Oct 8 18:49:33 c-3po sshd[7328]: Failed password for invalid user admin from 82.196.2.248 port 37212 ssh2 > Oct 8 20:54:32 c-3po sshd[17688]: Invalid user asd from 82.196.2.248 > Oct 8 20:54:32 c-3po sshd[17688]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=82.196.2.248 As I understand someone get acess to my server. I've used password protected ssh key when created server. I've got few questions: 1. How can I detect process that sends this auth requests? 2. How can hacker was able to get access to my server? How can I figure it out? 3. Is password access to server enabled when ssh key is used?
2 Answers
I don't see from logs that he gained access? (he only tried and failed, so you should considere using fail2ban or CSF)
Make sure you've installed:

1.) How To Protect SSH with fail2ban on Ubuntu 12.04;

2.) How To Install DenyHosts on Ubuntu 12.04; and

3.) How to Setup a Firewall with UFW on an Ubuntu and Debian Cloud Server;

Lastly, just b/c an SSH key is used does not disable password logins automatically. For a step-by-step guide on disabling password-logins, check out the tail of: How To Create SSH Keys with PuTTY to Connect to a VPS.
by Etel Sverdlov
fail2ban provides a way to automatically protect virtual servers from malicious behavior. This tutorial shows you how to install Fail2Ban, copy the Configuration File, configure the fail2ban defaults, and find out how to configure the ssh defaults. This tutorial describes the required steps to set up fail2ban on Ubuntu.
Have another answer? Share your knowledge.