大网数据广告活动
服务器运维问答

Unknown ssh connections found in lsof -i has my server been compromised?

· 52CE 我爱测

I have a Digital Ocean droplet running Ubuntu 14.04. I use it for running quick node.js tests on a publicly available server. I just logged in via SSH and did $ lsof -i to see what ports I was using. At the bottom of the list I n…

问题原文

原帖链接 · James · CC BY-SA 3.0

I have a Digital Ocean droplet running Ubuntu 14.04. I use it for running quick node.js tests on a publicly available server. I just logged in via SSH and did $ lsof -i to see what ports I was using. At the bottom of the list I noticed:

sshd    30952 root    3u  IPv4 66978103      0t0  TCP xxx.xxx.xxx.xxx:ssh->120.52.72.81:7810 (ESTABLISHED)
sshd    30953 sshd    3u  IPv4 66978103      0t0  TCP xxx.xxx.xxx.xxx:ssh->120.52.72.81:7810 (ESTABLISHED)

I didn't expect these ssh connections (it should only be me!) so I looked up the IP address and it seems to be in China. So what should I do now to check whether these ssh connections are malicious and if so what they may have done to the server. I'd rather not nuke it but if it's been compromised (since they have root access I presume it has!) then perhaps that's the simplest thing to do.

Update: Since writing the above, I have 2 different SSH connections so I presume it really is compromised.

sshd    31009 root    3u  IPv4 66979206      0t0  TCP xxx.xxx.xxx.xxx:ssh->221.194.44.218:50829 (ESTABLISHED)
sshd    31010 sshd    3u  IPv4 66979206      0t0  TCP xxx.xxx.xxx.xxx:ssh->221.194.44.218:50829 (ESTABLISHED)

If anyone can suggest a sensible approach to checking for a compromise/cleaning this up/seeing what's happened that would be great to help me learn (I'm such a n00b!).

Update 2: It appears that this isn't signs of a compromise but rather the signs of brute force log in attempts - see the comments from @bodgit and @ultrajohn below.

已采纳解答

原帖链接 · Falcon Momot · CC BY-SA 3.0

No, this isn't evidence of a compromise.

Any server on the Internet can expect regular attempts to brute SSH and other types of logins. These types of attacks are automated, and not targeted. Usually the goal of the attack is to install a bot that can be used to send spam or initiate more attacks. The attacks are usually dictionary-based.

Obviously, if some attacker is going to try a random username and password, they will start off by establishing a connection to your SSH server. That is what you are seeing in lsof (and would also see in netstat).

If you want to check for compromise, look at wtmp (type who), and look at the system logs. Audit records in syslog (like "session opened for user james") will shed some light.

You could also look for users you do not recognize, and inspect traffic and connections (the commandnetstat -nvlp can be handy) to see whether your server is running unexpected processes that are doing things like sending email or originating connections to other services.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。