谁动了我的sshd(消失的sshd,诡异)(+真相)
消失的sshd
上午一直登录在一台远程Linux服务器上,想拿一份最新的数据库数据来,于是用 mysqldump 导出并打包成 tar.gz;在本地的一台Linux服务器上执行 sftp,诡异的事情发生了。
?
[root@liunx0918 shtools]# sftp xxx.xxx.xxx.xxx
Connecting to xxx.xxx.xxx.xxx...
ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused
Couldn't read packet: Connection reset by peer
[root@liunx0918 shtools]#
?
也就是说,这台服务器并没有启动 sshd 服务,这怎么可能呢,我不是还 ssh 在上面吗?
?
赶快上去看一下(因为一直登录在上面,还是可以操作的),发现少了 /usr/sbin/sshd 进程。
[root@www mysql]$ ps -ef|grep sshd
root????? 1971???? 1? 0 10:08 ???????? 00:00:00 sshd: root@pts/0
root????? 8962? 1973? 0 15:05 pts/0??? 00:00:00 grep sshd
[root@www mysql]$
?
正常的系统是这样的:
[root@www mysql]$ ps -ef|grep sshd
root????? 1971???? 1? 0 10:08 ???????? 00:00:00 sshd: root@pts/0
root????? 4862???? 1? 0 11:46 ???????? 00:00:00 /usr/sbin/sshd
root????? 7207? 4862? 0 11:58 ???????? 00:00:00 sshd: root@pts/1
root????? 8962? 1973? 0 15:05 pts/0??? 00:00:00 grep sshd
[root@www mysql]$
?
?
当时的第一想法是,赶快把 sshd 启动起来。紧张啊
[root@www mysql]$ service sshd start
sshd: 未被识别的服务
[root@www mysql]$
?
在 /etc/init.d/ 下没有找到 sshd 脚本
[root@www mysql]$ ls /etc/init.d/sshd
ls: /etc/init.d/sshd: 没有那个文件或目录
[root@www mysql]$
?
发现 openssh-server 包不翼而飞
[root@www mysql]$ rpm -qa | grep ssh
openssh-clients-4.3p2-82.el5
openssh-4.3p2-82.el5
[root@www mysql]$
?
正常的系统肯定有,不然怎么 ssh 登录。
[root@liunx0918 backup]# rpm -qa | grep ssh
openssh-4.3p2-36.el5
openssh-clients-4.3p2-36.el5
openssh-server-4.3p2-36.el5
[root@liunx0918 backup]#
?
幸好,还有一个终端连在上面,赶快安装一下:
[root@www mysql]$ yum install -y openssh-server
?
然后重启 sshd 服务
[root@www mysql]$ service sshd start
?
这样终于可以从远程登录和下载文件了。松了一口气
关键的问题是:这个 sshd 为什么会不见了呢???黑客?!
?
在 .bash_history 文件中找到了这样的信息
yum remove tcp_wrappers
yum remove tcp_wrappers.i386 0:7.6-40.7.el5
?
在 /var/log/yum.log 中找到了如下信息
Jun 11 10:24:43 Erased: openssh-server
Jun 11 10:24:43 Erased: tcp_wrappers
Jun 11 11:46:05 Installed: tcp_wrappers-7.6-40.7.el5.i386
Jun 11 11:46:05 Installed: openssh-server-4.3p2-82.el5.i386
后面两条是我操作的,前面两条不是我操作的,而是别人真的把openssh-server给删了。
?
后面问了一下,原来是云主机提供方帮助我们解决“无法远程访问某个服务”的问题,上去做了一些操作,没想到他会干出这样的事情来。
不过还好,(1)发现得及时;(2)并非黑客所为;
?
可见:服务器的登录权限管控一定要做好,不然都不知道怎么死的。
?
?
?
?
?